MATLAB Changing the scale of the y-axis

  • Thread starter Thread starter EngWiPy
  • Start date Start date
  • Tags Tags
    Scale
AI Thread Summary
In Octave, to adjust the y-axis scale for better detail representation in a figure with multiple curves, users can utilize the semilogy() function to implement a logarithmic scale, which allows for smoother variations in scale. This method is effective for displaying data with significant differences in magnitude, especially below a certain threshold like 0.4. Alternatively, users can manually rescale their data and customize the axis tick marks by accessing the axes object with gca. Through this object, properties such as YScale and YTick can be modified to achieve the desired tick spacing and scaling on the y-axis without needing to separate the curves into different figures.
EngWiPy
Messages
1,361
Reaction score
61
Hi,

I am using Octave to do simulations. I have multiple curves in the same figure. I want to change the scale of y-axis after some point to capture more details. For example, the default y-ticks are 1, 0.8, 0.6, 0.4. 0.2, 0. Between 1 and 0.4 the default scale is good for my curves, but between 0.4 and 0, I want to change the scale to 0.4, 0.1, 0.01, 0.001, 0.0001, ... Can I do that on the same figure or I have to separate the curves?

Thanks
 
Physics news on Phys.org
I tried

Code:
set(gca,'ytick',[my_ticks])

but this doesn't change the scale. Rather, it keeps the same distance between the default ticks, and add more ticks near the zero. I want to change the distance between the ticks below 0.4.
 
Not precisely what you asked for but maybe near enough: use a log scale on the y axis. To do this, replace plot(...) by semilogy(...).
 
  • Like
Likes FactChecker and EngWiPy
semilogy() is a nice way because it achieves the result while also "smoothly" varying the scale in some commonly understood way.

A more involved way would be to rescale your data however you see fit and then relabel the axis tick marks accordingly.
 
  • Like
Likes EngWiPy and FactChecker
If you simply call

Code:
ax = gca;

You get a handle to the axes object in the figure. You can then modify the properties of the object to do almost anything you want. See the documented properties of the object here. YScale can change the scale of the y-axis to log, YTick sets the tick values, etc...
 
  • Like
Likes EngWiPy

Similar threads

Replies
9
Views
5K
Replies
1
Views
5K
Replies
5
Views
4K
Replies
1
Views
3K
Replies
4
Views
1K
Replies
10
Views
3K
Back
Top