Amar Sangha
Amar Sangha

Reputation: 11

How do you edit the x-axis, but not change the scale of the graph/2D image on Matlab?

I have a time spatial 2D graph, and currently the axis is 1-101. However I need to change these values so it -0.0005 to 0.0005; however when I change put these values in the X limits, the graph just goes to -0.0005-0.0005 and cuts out all the data.

I would just like to change the x-axis data values independent of the graph. If this makes sense?

Upvotes: 1

Views: 2822

Answers (2)

not link
not link

Reputation: 870

You would need to change the XTickLabels of the current axis. You can do this by modifying the XTickLabel as seen in the example below:

plot(1:5)
set(gca,'Xtick',1:5,'XTickLabel',{'7', '8', '9', '10', '11'})

Upvotes: 0

user1284631
user1284631

Reputation: 4616

You should change the ticklabels of the axis (that is, the strings that are shown for the ticks), not the axis values.

Alternatively, you can re-scale the image (for example, specifying x and y vectors in the imagesc() command.

edit: see here for an example: http://www.mathworks.nl/help/matlab/creating_plots/setting-axis-parameters.html#f6-27790

search in the page for: "You can adjust the axis tick-mark locations and the labels appearing at each tick mark."

Upvotes: 1

Related Questions