ParametricPlot and log scale axes in Mathematica

Click For Summary

Discussion Overview

The discussion revolves around creating parametric plots with logarithmic axes in Mathematica. Participants explore methods to achieve logarithmically spaced tick marks on the axes, particularly in the context of the Bethe-Bloch equation for energy deposit.

Discussion Character

  • Technical explanation
  • Exploratory
  • Debate/contested

Main Points Raised

  • One participant seeks guidance on how to create a parametric plot with logarithmic axes in Mathematica, specifically mentioning the Bethe-Bloch equation.
  • Another participant suggests applying the Log[] function to the plotted variables to create a semi-log plot, where the Y-axis is logarithmic and the X-axis is linear.
  • A subsequent reply clarifies that the suggested method does not produce logarithmically spaced tick marks, which is the original request.
  • One participant expresses doubt about Mathematica's capability to produce the desired plot with logarithmic tick marks, indicating that plotting the logarithm of the variables may be the only solution.
  • A different participant shares a link and an example of using a simple function with ParametricPlot to achieve a logarithmic scale.
  • Another participant provides a detailed code snippet that includes custom tick marks for a logarithmic Y-axis in a parametric plot, which is acknowledged as effective by another participant.
  • There is a light-hearted comment questioning why the task should be difficult, reflecting on the complexity of the issue.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best method to achieve logarithmic tick marks in parametric plots. Multiple approaches are discussed, and uncertainty remains regarding Mathematica's capabilities in this context.

Contextual Notes

Some participants express limitations in their understanding of the problem, and there are unresolved questions about the ease of implementing logarithmic scales in parametric plots.

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 ·
Replies
1
Views
5K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 8 ·
Replies
8
Views
6K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 4 ·
Replies
4
Views
5K
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K