Reputation: 249
How do I get the x-axis to only show those two values when I plot?
Upvotes: 1
Views: 5172
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:
See Change Axis Tick Values and Labels in the documentation for more details.
Upvotes: 1