Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change x axis labeling independent of x values?

Imagine I am plotting e.g. this:

plot(1:1500,1:1500)

This will look like the image below, with the x axis starting at 0 and going up to 1500.

Now I don't want to have that labeling, but instead the x axis labeling shall start with e.g. 1 and then end at 151 (increase by 1/10 for every point on the x axis, additionally an offset of 1).

I just want to change the labeling of the x axis, I don't want to change the x input vector to the plot function nor do I want to plot other points. I just want the x labeling to start at a different offset and increase in another step size, independent of the x values passed to the plot function.

Is that possible? How? It would make some things easier for me. Thanks for any hint!

enter image description here

like image 918
stefan.at.wpf Avatar asked Feb 20 '23 00:02

stefan.at.wpf


1 Answers

You could customize the tick marks using the XTick and XTickLabel axis properties.

Example:

x = 1:7;
y = rand(size(x));
plot(x,y)
set(gca, 'XTickLabel',{'Mon','Tue','Wed','Thu','Fri','Sat','Sun'})

screenshot

like image 121
Amro Avatar answered Mar 03 '23 04:03

Amro