octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #63820] ylim settings incorrect


From: Rik
Subject: [Octave-bug-tracker] [bug #63820] ylim settings incorrect
Date: Thu, 23 Feb 2023 11:25:03 -0500 (EST)

Follow-up Comment #7, bug #63820 (project octave):

I can reproduce this on the development branch.  Octave shouldn't have this
issue, and it is very likely related to the single precision used in OpenGL. 
For the time being, scaling your data and then changing the labels  is the
best workaround.  Here is an automated way to do that based on a callback
function which "listens" for changes on the "ytick" property of the axes.


clear all;
figure()
x = 1:10;
y = 1e-11:1e-11:1e-10;
ynew = 1e10 * y;
plot (x, ynew);

function cb_ytick (h, ~)
  ytick = get (h, 'ytick');
  ytick ./= 1e10;
  ylabels = arrayfun (@(s) sprintf ("%.2g", s), ytick, 'uniformoutput',
false);
  set (h, 'yticklabel', ylabels);
endfunction

addlistener (gca, 'ytick', @cb_ytick);
cb_ytick (gca);  # Call once after initial plot to set limits


Once the plot is made and the listener is active you can execute normal
commands such as


# manually set Y limits
ylim ([0, 1.5])
# Have Octave choose Y limits
ylim auto




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63820>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]