Mathematica ParametricPlot and log scale axes in Mathematica

AI Thread Summary
Creating a parametric plot with logarithmic axes in Mathematica requires applying the Log[] function to the variables being plotted. However, simply using Log[] does not produce logarithmically spaced tick marks, which is a key requirement for the user. After some exploration, it appears that Mathematica does not natively support this feature in a straightforward manner. A workaround involves manually defining tick marks using custom code to achieve the desired logarithmic spacing. Ultimately, the discussion highlights the limitations of Mathematica in this context while providing a potential solution.
pastro
Messages
15
Reaction score
0
Hello,

I have been trying to make a parametric plot with logarithmic axes in Mathematica, but have been unable to find an option to do this. Can someone tell me how to do this? My code is below, and for reference, EnergyScint is the Bethe-Bloch equation for energy deposit for a fully ionized oxygen core passing through a 1/2 inch slab of scintillator, which I am plotting as a function of \beta \gamma

ParametricPlot[{b (1 - b^2)^(-1/2), EnergyScint}, {b, .1, .999}, PlotRange -> All]

Thanks!
 
Physics news on Phys.org
Hi,

I do not understand well the problem, but I suppose you are missing to apply the Log[] function to the functions which you want to plot logarithmically. Example:

Code:
ParametricPlot[{b (1 - b^2)^(-1/2), Log[10, EnergyScint[b]]}, {b, .1, .999}, PlotRange -> All]

This will create a SemiLog plot in which the Y axis will have logarithmic scale and the X axis will be linear.

Hope this helps!
 
Thanks, but what I am really looking for is the tick marks to be logarithmically spaced, the same way LogPlot[] produces tick marks, but as a parametric plot. Your solution does not produce logarithmically scaled tick marks, just the log of the plotted variables on a linear scale.

After researching this issue, I am beginning to believe that Mathematica is unable to produce such a plot (at least, not simply...) and plotting the Log[] of the variables is indeed the only (highly non-ideal) solution.

Thanks!
 
Maybe this can help:
http://www-binf.bio.uu.nl/vitaly/mathematica/

I'd tried it with a simple function (10^x) by just replacing the Plot function with a ParametricPlot[{x,Log[10,10^x]},{x,0,10}] and it worked just fine.

Hope this does it.
 
Last edited by a moderator:
This is the code as I use it:

Code:
(* Y-axis has log ticks *)

Clear[step,y1,y2,yticks,yticks2];

step=1;           (* step in logs *)
y1=0;               (* initial value with a label - log *)
y2=4;               (* last value with a label - log *)


yticks=Join[Flatten[Table[Table[{Log[10,i],""},{i,10^j,10^(step+j),10^(j+(step-1))}],{j,y1,y2-step,step}],1],Table[{i,If[i==-1,"10^-1",If[i<0,("10^-")^-i,("10")^i]]},{i,y1,y2,step}]];


yticks2=Join[Flatten[Table[Table[{Log[10,i],""},{i,10^j,10^(step+j),10^(j+(step-1))}],{j,y1,y2-step,step}],1],Table[{i,""},{i,y1,y2,step}]];

ParametricPlot[{t, Log[10, 10^t]}, {t, 0, 10}, Frame -> {True, True, False, False}, FrameTicks -> {Automatic, yticks, {}, yticks2}, PlotRange -> {y1 - 0.00001`, y2}]
 
Thanks, that seems to do the job!
 
You're welcome.

Anyway it shouldn't be that hard, isn't it? ;)
 

Similar threads

Replies
1
Views
5K
Replies
9
Views
5K
Replies
8
Views
6K
Replies
5
Views
3K
Replies
1
Views
6K
Replies
1
Views
4K
Replies
4
Views
5K
Replies
3
Views
3K
Back
Top