Changing the scale of the y-axis

  • Context: MATLAB 
  • Thread starter Thread starter EngWiPy
  • Start date Start date
  • Tags Tags
    Scale
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 2K views
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   Reactions: 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   Reactions: 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   Reactions: EngWiPy