Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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. – Dr. belisarius Feb 22 '13 at 2:33
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. – Mr.Wizard Feb 22 '13 at 2:41
thanks for help! – molkee Feb 22 '13 at 3:04
up vote 1 down vote accepted

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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