how to put two different units on my axis
4 views (last 30 days)
Show older comments
I have a plot with equal axis but i need the x-axes to have twice the unit as the y. 1:2
how do i do that??
Dorrit
2 Comments
Andrew Newell
on 12 May 2011
Do you mean that you want (for example) the X axes to be from 0 to 2 and the Y axes from 0 to 1?
Or do you mean that you want X and Y to be both from 0 to 1 but have twice as many tick marks on the X axis?
Accepted Answer
Kelly Kearney
on 12 May 2011
Do you mean you want the length of the axes to be the same, but with a 2:1 ratio? Try adjusting the aspect ratio:
x = 0:0.1:1;
y = 2*x;
plot(x,y);
set(gca, 'dataaspectratio', [1 2 1]);
4 Comments
More Answers (1)
Walter Roberson
on 12 May 2011
Possibly set() XMinorTick 'on' for the axes would be sufficient ?
If not, then set() the XTick to the tick locations you want. (Note: if you do that, then if you zoom or pan then you will want to use the appropriate callback in those modes to create new XTick according to what is visible.)
See Also
Categories
Find more on Formatting and Annotation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!