# How to export data from ListLogLogPlot [closed]

I have a ListLogLogPlot, for example:

data1 = ListLogLogPlot[Table[{i^2, i^(1/3)}, {i, 1, 20, 1}]]


Note: I know that there is no need to export the data in the example, because the data are explicit as specified in the Table, however, in my real problem, the data in Table are calculated from the other data, which are not explicit. Thus, I try to export the data using the following code into a .txt or .dat file for the subsequent processing.

datapart1 = Cases[data1, Line[data_] :> data, -4, 1][[1]];

Export["datapart1.txt", datapart1, "Table"]


However, the first line gives me an error:

Part::partw: Part 1 of {} does not exist. >>

Accordingly, the export gives just an empty file.

## closed as off-topic by Szabolcs, user9660, m_goldberg, MarcoB, Bob HanlonJan 18 '16 at 17:53

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Szabolcs, Community, m_goldberg, MarcoB, Bob Hanlon
If this question can be reworded to fit the rules in the help center, please edit the question.

• I don't understand the question. ListLogLogPlot always takes data that is explicitly specified as data points. If you already have this data, why can't you export it directly? If you don't already have this data, how can you use ListLogLogPlot at all? – Szabolcs Jan 18 '16 at 8:46
• I understood this such that you somehow produce a list. In your example above this list is given by lst=Table[{i^2, i^(1/3)}, {i, 1, 20, 1}]  , but in a real case - by a much more complex procedure, right? Then you need to make another list out of it, such that it can be plotted as a log-log plot. Am I right? If so, you can do a simple trick. After you have created a list lst do the following: lst/.{x_,y_}->{Log[x],Log[y]}  . Done. This you may export. Have fun! – Alexei Boulbitch Jan 18 '16 at 8:57
• Hi, @ Alexei Boulbitch, you got the point of my problem. Trying it. Thanks! – W. Robin Jan 18 '16 at 9:42
• @AlexeiBoulbitch, in this case you don't have to even use a replacement rule, you can just use Log[lst] since Log is Listable. – Jason B. Jan 18 '16 at 10:00
• Based on the comments the OP effectively wanted to use ListLogLogPlot to compute (not plot) the logarithm of the data. As Jason notes, this should be done with Log instead. Voting to close as simple mistake. Please clarify if I misunderstood. – Szabolcs Jan 18 '16 at 11:46

You are trying to get Cases of Line in your plot. There are no lines in your plot, only points.

data1 =
ListLogLogPlot[Table[{i^2, i^(1/3)}, {i, 1, 20, 1}]];
Cases[data1, Point[data_] :> data, Infinity]
(* {{{0., 0.}, {1.38629, 0.231049}, {2.19722,
0.366204}, {2.77259, 0.462098}, {3.21888, 0.536479}, {3.58352,
0.597253}, {3.89182, 0.648637}, {4.15888, 0.693147}, {4.39445,
0.732408}, {4.60517, 0.767528}, {4.79579, 0.799298}, {4.96981,
0.828302}, {5.1299, 0.854983}, {5.27811, 0.879686}, {5.4161,
0.902683}, {5.54518, 0.924196}, {5.66643, 0.944404}, {5.78074,
0.963457}, {5.88888, 0.98148}, {5.99146, 0.998577}}} *)


You had originally used a [[1]] in your code, which for just one plotted list had the effect of removing some extraneous curly brackets. But for multiple plotted lists, it takes just the first list. Without the [[1]], it is more general,

Cases[
ListLogLogPlot[Table[{i^2, i^(1/3 + m)}, {m, 0, 4, 1}, {i, 1, 20, 1}]]
, Point[data_] :> data, Infinity]
(* {{{0., 0.}, {1.38629, 0.231049}, {2.19722,
0.366204}, {2.77259, 0.462098},............
......................... {5.78074, 12.5249}, {5.88888,
12.7592}, {5.99146, 12.9815}}} *)


Of course, as Szabolcs pointed out, you can get the same thing by typing

N @ Log @ Table[{i^2, i^(1/3 + m)}, {m, 0, 4, 1}, {i, 1, 20, 1}]

• @ Jason B, thanks. Can I change Line into Point within Cases to export the point coordinates? Because my ListLogLogPlot takes very long time to generate the curve. – W. Robin Jan 18 '16 at 9:48
• @W.Robin that works as well. As long as you have the plot in a notebook you can extract the underlying points. – Jason B. Jan 18 '16 at 10:05
• @ Jason B, there are 5 Table in my ListLogLogPlot, they are placed in a bracket as {Table1, Table2, ..., Table5}. Use Cases[data1, Point[data_] :> data, -4, 1][[1]], it can only export part of the points, seems only those in the first Table. Help... – W. Robin Jan 18 '16 at 10:30
• Right on, that's because of the 1 you gave as the fourth argument to Cases and also because of the [[1]] you had at the end. see the update above. – Jason B. Jan 18 '16 at 10:42