ss1111
ss1111

Reputation: 249

How to label specific points on x-axis in MATLAB?

enter image description here

How do I get the x-axis to only show those two values when I plot?

Upvotes: 1

Views: 5172

Answers (1)

am304
am304

Reputation: 13876

Use a combination of XTick and XTickLabel, e.g.:

x = -pi:pi/360:pi;
y = sin(x)
plot(x,y)
doc xtick
set(gca,'XTick',[-pi/2 pi/2],'XTickLabel',{'-\pi/2','\pi/2'})

which gives something like this:

enter image description here

See Change Axis Tick Values and Labels in the documentation for more details.

Upvotes: 1

Related Questions