ParametricPlot and log scale axes in Mathematica

In summary: No, it is not that hard. If you can plot a linear function on a linear scale, you can plot a logarithmic one. However, Mathematica does not provide a straightforward way to do this.
  • #1
pastro
15
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
  • #2
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!
 
  • #3
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!
 
  • #4
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:
  • #5
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}]
 
  • #6
Thanks, that seems to do the job!
 
  • #7
You're welcome.

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

1. How do I plot a parametric function in Mathematica?

To plot a parametric function in Mathematica, use the ParametricPlot command and specify the x and y coordinates as a function of a parameter t. For example, if the function is x = cos(t) and y = sin(t), the code would be ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 2 Pi}]. This will produce a plot of the parametric function over the specified range of t values.

2. How do I change the scale of the axes in a parametric plot?

To change the scale of the axes in a parametric plot, use the ScalingFunctions option in the ParametricPlot command. For example, if you want to use a logarithmic scale for the x-axis, you would use the option ScalingFunctions -> {"Log", None}. This will plot the x-axis on a logarithmic scale while keeping the y-axis on a linear scale.

3. How do I add labels and titles to a parametric plot?

To add labels and titles to a parametric plot, use the options AxesLabel and PlotLabel in the ParametricPlot command. For example, if you want to label the x-axis as "x" and the y-axis as "y", you would use the option AxesLabel -> {"x", "y"}. To add a title to the plot, use the option PlotLabel -> "Title".

4. Can I combine multiple parametric plots in one graph?

Yes, you can combine multiple parametric plots in one graph by using the Show command. Simply plot each parametric function separately using the ParametricPlot command, and then use the Show command to display them together. You can also use the options PlotStyle and PlotLegends to customize the appearance and add a legend to the combined plot.

5. How do I change the color and style of a parametric plot?

To change the color and style of a parametric plot, use the options PlotStyle and PlotTheme in the ParametricPlot command. For example, if you want to plot a dashed line in red, you would use the option PlotStyle -> {Red, Dashed}. You can also use the PlotTheme option to quickly change the overall appearance of the plot.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
6K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
  • Classical Physics
Replies
1
Views
1K
Back
Top