My question is based on the discussion that I started: Plot, extract data to a file

The method proposed works well for the Plot command, but what about LogLinearPlot? This was the original motivation when I started the thread. I wanted to extract the data for LogLinearPlot, because I wanted a tighter grid for r $\approx$ 0. Otherwise, I could have just used Table and wouldn't have started the thread. This doesn't work with Table, which produces a uniform grid.

Anyways, this is my code:

LogLinearPlot[{f[r]*r, 0}, {r, 0.0001, 1000}, PlotRange -> {-0.5, 0.2}, MaxRecursion -> 15]
data = Cases[%, Line[data_] :> data, -4, 1][[1]];
Export["~/Desktop/1.dat", SetAccuracy[%, 10], Alignment -> Center]

The catch is that it produces a relative positions of the points on the r axis for the 1st column (r coordinates of the points they would have if the r-axis wasn't set to be logarithmic on the plot).

For example,

-9.210340043    -0.044128619
-9.210320733    -0.04412862

whereas I was expecting something like this:

 0.000110000    -0.044128619
 0.000170000    -0.04412862

The origin of the "fictitious" and real axes coincide. How do I get the actual values of r?

  • $\begingroup$ Your attempt to use the Plot[] mesh, although achievable, doesn't seem justified. You could design your own "meshing" algorithm, fitted specifically to your problem. $\endgroup$ Feb 22, 2013 at 2:33
  • $\begingroup$ I posted an answer showing how to adapt both of the methods I previously gave. In the future consider mentioning your actual use in questions as that will help answers to be better on target. $\endgroup$
    – Mr.Wizard
    Feb 22, 2013 at 2:41

1 Answer 1


You just need to to invert the Log operation that is done on the $x$ data, with Exp:

gr = LogLinearPlot[Sin[x], {x, 1, 10}]

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

data = {Exp@#, #2} & @@@ data;


Mathematica graphics

Mathematica graphics

Alternatively you could use the other method, which may be simpler in this case:

{gr, {data}} =
   LogLinearPlot[Sin[x], {x, 1, 10}, EvaluationMonitor :> Sow[{x, Sin@x}]]



Mathematica graphics

Mathematica graphics


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.