Is it possible to create a plot with tick labels as multiples of pi in MATLAB?

In summary, You can set the tick marks and labels on an axis in MATLAB, but it does not support displaying tex characters in tick labels. The tick labels can be controlled using the 'XTick' and 'XTickLabel' properties. However, these do not interpret TeX character sequences.
  • #1
danago
Gold Member
1,123
4
I want to create a plot, but want the horizontal axis to have increments as multiples of pi eg. {0, pi/2, pi, 3pi/2, ... }

Is this at all possible in matlab?
 
Physics news on Phys.org
  • #2
Yes - you can set where the tick marks are on an axis:

This will control where the ticks go (use whatever range you want):
set(gca,'XTick',0:pi/2:3*pi/2)

(Note that gca returns the handle for the current set of axes)

This will control the labels for the ticks:
set(gca,'XTickLabel',{'0','pi/2','pi','3pi/2'})


So you can attach text labels to all of your tick marks - make sure that you have the correct number of labels - I think if you have more tick marks than labels, MATLAB will just cycle back through your list of labels for the extra tick marks. Also, I know that MATLAB supports some tex and latex formatting so that you could display [tex] \pi [/tex] instead of pi, but I'm not sure if that is supported for tick labels (and if it is I'd have to play around with it to figure out how that works).
 
  • #3
Thanks very much, exactly what i was after :smile:
 
  • #4
Unfortunately, MATLAB can't display tex characters in tick labels.

From MATLAB help - keyword: Axes properties:

...
Note that tick labels do not interpret TeX character sequences (however, the Title, XLabel, YLabel, and ZLabel properties do).
 

What is the purpose of using a radian scale in MATLAB?

The radian scale is used in MATLAB to measure angles in radians instead of degrees. This is important because many mathematical functions and formulas use radians as the default unit for angles.

How do I plot data on a radian scale in MATLAB?

To plot data on a radian scale in MATLAB, you can use the polarplot function. This function takes in polar coordinates (r, theta) and plots the data on a polar coordinate system with theta measured in radians.

Can I change the scale of a plot from degrees to radians in MATLAB?

Yes, you can change the scale of a plot from degrees to radians in MATLAB by using the xticklabels function. This function allows you to specify the labels for the x-axis, so you can change the labels from degrees to radians.

How do I adjust the range of the radian scale in a plot?

To adjust the range of the radian scale in a plot, you can use the rticks function. This function allows you to specify the values for the tick marks on the radial axis, so you can adjust the range of the radian scale to fit your data.

Are there any other ways to plot data on a radian scale in MATLAB?

Yes, there are other ways to plot data on a radian scale in MATLAB. You can also use the polaraxes function to create a polar axes object and then use the plot function to plot data on the polar axes. Additionally, you can use the compass function to create a polar plot with a compass-like appearance.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
745
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
568
Back
Top