Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Want to change the range of a single axis of a plotyy figure

Asked by Michael on 11 Dec 2012

Hi

I want my x-axis to be tight to the data on a plotyy graph. I can't seem to do it without messing up the axes.

My data ranges from 1e-5 to 1e3 and it's a semilogx plotting function. Is there a way I can use axis([...]) to specify all three ranges (x, y1, y2) at once?

Thanks for any help Mike

0 Comments

Michael

Products

No products are associated with this question.

2 Answers

Answer by Walter Roberson on 11 Dec 2012
Accepted answer

There is no way to specify the limits all at once.

[ax h1 h2] = plotyy(x,y1,x,y2);
xlim(ax(1), ...);
xlim(ax(2), ...);
ylim(ax(1), ...);
ylim(ax(2), ...);

0 Comments

Walter Roberson
Answer by Muruganandham Subramanian on 11 Dec 2012
Edited by Muruganandham Subramanian on 11 Dec 2012
figure;
ylim([1e-5 1e3]);

or

goto Edit -> Axes Properties -> then select X axis and change range as your need

3 Comments

Michael on 11 Dec 2012

I think there are two axes and both of these solutions only change one of the two, resulting in an overlapping set of axes. My x data is the same for both plots, so I'd like the x axis to be unique.

Muruganandham Subramanian on 11 Dec 2012

If you need to change x axis range is b/w 1e-5 to 1e3, you can use

xlim([1e-5 1e3]) 

or if it's not, can you explain precisely?

Michael on 11 Dec 2012

That is exactly what I want to do, but it's not working because it seems to generate a second axis. The original axis (not tight) is still there. I think the fact that it's a plotyy figure has an influence on the answer.

Muruganandham Subramanian

Contact us