Mercurial > octave
changeset 22930:f2d2edab5c66
Change basevalue of bar charts when axes scale changed to log (bug #41944).
* __bar__.m (__bar__): Set basevalue to 0 (linear) or 1 (log) based on yscale
property of axes. Add listener on axes yscale property to call
update_basevalue_logscale.
* __bar__.m (update_basevalue_logscale): New call back function which sets basevalue
to 0 if yscale is "linear" or 1 if yscale is "log".
* graphics.cc (axes::properties::get_axis_limits): Call warning_with_id and
ID="Octave:negative-data-log-axis" when non-positive data found for log axes
object.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 22 Dec 2016 15:31:39 -0800 |
parents | dec22bceafa2 |
children | 8133da976602 |
files | libinterp/corefcn/graphics.cc scripts/plot/draw/private/__bar__.m |
diffstat | 2 files changed, 23 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc Thu Dec 22 15:18:02 2016 -0500 +++ b/libinterp/corefcn/graphics.cc Thu Dec 22 15:31:39 2016 -0800 @@ -6904,7 +6904,8 @@ } if (min_val <= 0 && max_val > 0) { - warning ("axis: omitting non-positive data in log plot"); + warning_with_id ("Octave:negative-data-log-axis", + "axis: omitting non-positive data in log plot"); min_val = min_pos; } // FIXME: maybe this test should also be relative?
--- a/scripts/plot/draw/private/__bar__.m Thu Dec 22 15:18:02 2016 -0500 +++ b/scripts/plot/draw/private/__bar__.m Thu Dec 22 15:31:39 2016 -0800 @@ -30,7 +30,12 @@ width = 0.8; group = true; histc = NA; - bv = 0; # BaseValue + ## BaseValue + if (strcmp (get (hax, "yscale"), "log")) + bv = 1; + else + bv = 0; + endif if (nargin > 1 && isnumeric (varargin{2})) x = varargin{1}; @@ -336,6 +341,7 @@ ## Add listeners outside of for loop to prevent constant updating during ## creation of plot when patch objects are added. addlistener (hax, "xlim", @update_xlim); + addlistener (hax, "yscale", {@update_basevalue_logscale, hg}); addlistener (h_baseline, "ydata", @update_baseline); addlistener (h_baseline, "visible", @update_baseline); @@ -357,6 +363,20 @@ endfunction +function update_basevalue_logscale (hax, ~, hg) + if (strcmp (get (hax, "yscale"), "log")) + warning ("off", "Octave:negative-data-log-axis", "local"); + if (get (hg, "basevalue") == 0) + set (hg, "basevalue", 1); + endif + else +# warning ("off", "Octave:negative-data-log-axis", "local"); + if (get (hg, "basevalue") == 1) + set (hg, "basevalue", 0); + endif + endif +endfunction + function update_baseline (h, ~) visible = get (h, "visible");