Changing the scale of the y-axis

  • Context: MATLAB 
  • Thread starter Thread starter EngWiPy
  • Start date Start date
  • Tags Tags
    Scale
Click For Summary

Discussion Overview

The discussion focuses on how to change the scale of the y-axis in Octave when plotting multiple curves in the same figure. Participants explore methods to adjust the y-ticks for better detail representation, particularly in the lower range of the y-axis.

Discussion Character

  • Technical explanation, Exploratory, Debate/contested

Main Points Raised

  • One participant seeks to change the y-axis scale to capture more detail below a certain threshold, suggesting a need for custom tick marks.
  • Another participant reports that using the command set(gca,'ytick',[my_ticks]) does not achieve the desired effect, as it maintains the distance between default ticks while adding more ticks near zero.
  • A suggestion is made to use a logarithmic scale with semilogy(...) as a potential solution, which could provide a smoother variation in scale.
  • Another participant notes that semilogy() could be beneficial for achieving the desired effect while adhering to a commonly understood scaling method.
  • A further suggestion involves obtaining a handle to the axes object using ax = gca; to modify properties directly, including changing the y-axis scale and setting tick values.

Areas of Agreement / Disagreement

Participants express differing views on the best approach to change the y-axis scale, with no consensus on a single solution. Multiple methods are proposed, each with its own implications and limitations.

Contextual Notes

Participants do not fully resolve the issue of how to effectively change the y-axis scale, and there are limitations regarding the effectiveness of the proposed commands and methods in achieving the desired outcome.

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

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K