Changing the scale of the y-axis

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

This discussion focuses on changing the y-axis scale in Octave for better visualization of multiple curves in a single figure. Users can utilize the semilogy() function to implement a logarithmic scale, which effectively adjusts the spacing of y-ticks for values below 0.4. Alternatively, accessing the axes object with ax = gca; allows for manual adjustments of properties such as YScale and YTick to customize the y-axis further. These methods provide flexibility in displaying data with varying scales on the same graph.

PREREQUISITES
  • Familiarity with Octave programming environment
  • Understanding of plotting functions in Octave
  • Knowledge of logarithmic scales and their applications
  • Basic experience with axes properties in graphical representations
NEXT STEPS
  • Explore the semilogy() function in Octave for logarithmic plotting
  • Research how to manipulate axes properties using gca in Octave
  • Learn about customizing tick marks and labels in Octave plots
  • Investigate data rescaling techniques for better visualization
USEFUL FOR

This discussion is beneficial for data analysts, researchers, and engineers using Octave for simulations who need to effectively visualize data with varying scales on the same plot.

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
2K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K