diff --git a/configure.ac b/configure.ac index 5fb73aba1c..bbe372426e 100644 --- a/configure.ac +++ b/configure.ac @@ -3068,7 +3068,7 @@ if test $link_all_deps = yes; then OCT_GUI_LINK_DEPS="libgui/liboctgui.la $OCT_LINK_DEPS" MKOCTFILE_OCTAVE_LINK_DEPS="$LIBOCTINTERP_LINK_DEPS $MKOCTFILE_LIBOCTAVE_LINK_DEPS" - MKOCTFILE_OCT_LINK_DEPS="$LIBOCTINTERP $LIBOCTAVE" + MKOCTFILE_OCT_LINK_DEPS="-L${octlibdir} $LIBOCTINTERP $LIBOCTAVE" LIBOCTINTERP_LINK_DEPS="$LIBOCTINTERP_LINK_DEPS $LIBOCTAVE_LINK_DEPS" LIBOCTINTERP_LINK_OPTS="$LIBOCTINTERP_LINK_OPTS $LIBOCTAVE_LINK_OPTS" @@ -3082,7 +3082,7 @@ else OCT_LTLINK_DEPS="$OCT_LINK_DEPS" OCT_GUI_LINK_DEPS="libgui/liboctgui.la $OCT_LINK_DEPS" - MKOCTFILE_OCT_LINK_DEPS="$LIBOCTINTERP $LIBOCTAVE" + MKOCTFILE_OCT_LINK_DEPS="-L${octlibdir} $LIBOCTINTERP $LIBOCTAVE" ;; darwin*) dnl Contains variables that are defined and undefined at this point, @@ -3220,10 +3220,11 @@ AC_CONFIG_COMMANDS_PRE([ eval man1ext="\"$man1ext\"" eval infofile="\"$infofile\"" - ## Also expand MKOCTFILE_DL_LDFLAGS, because it may depend on the values + ## Also expand the following variables because they may depend on the values ## of variables expanded above. eval MKOCTFILE_DL_LDFLAGS="\"$MKOCTFILE_DL_LDFLAGS\"" + eval MKOCTFILE_OCT_LINK_DEPS="\"$MKOCTFILE_OCT_LINK_DEPS\"" ]) ### Do substitutions in Makefiles and other files that hold configuration info. diff --git a/etc/NEWS.9.md b/etc/NEWS.9.md index 1a436c8c87..ba7c62c2ec 100644 --- a/etc/NEWS.9.md +++ b/etc/NEWS.9.md @@ -17,12 +17,14 @@ Summary of bugs fixed for version 9.3.0 (tbd): Improve input validation to ensure `opt` is one of 0, 1, or []. (bug #66021). - `interp2`: Provide a meaningful error message if the input reference array is a vector (bug #66086). +- `legend` icons now inherit the "facelalpha" property to match appearance of + patch and surface graphics objects. +- `barh` properties now better match equivalent `bar` plot. Changing + `horizontal` property for a bar or barh plot now consistently updates + properties to match redrawn plot. ### GUI -- `legend` icons now inherit the "facelalpha" property from to match - appearance of patch and surface graphics objects. - ### Build system / Tests - `jupyter-notebook` test no longer fails if a figure window is open diff --git a/scripts/plot/appearance/legend.m b/scripts/plot/appearance/legend.m index 9259550230..5cf410bc49 100644 --- a/scripts/plot/appearance/legend.m +++ b/scripts/plot/appearance/legend.m @@ -2279,16 +2279,14 @@ function update_legend_position (hl, sz) ## Verify alpha parameter inherited by legend patch objects. ## Only facealpha currently implemented. -%!test <*66314> +%!testif ; any (strcmp (graphics_toolkit (), {"fltk", "qt"})) <*66314> %! hf = figure ("visible", "off"); %! unwind_protect %! hax = axes ("parent", hf); %! hp = patch (hax); %! set (hp, "facealpha", 0.5); -%! hleg = legend (hax); -%! legprops = get(hleg); -%! legpatchidx = find (strcmp (get (legprops.children, "type"), "patch")); -%! assert (get (legprops.children(legpatchidx), "facealpha"), 0.5); +%! hl = legend (hax); +%! assert (get (findobj (hl, "type", "patch"), "facealpha"), 0.5); %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect diff --git a/scripts/plot/draw/bar.m b/scripts/plot/draw/bar.m index 1af06d9d44..6e8dde11a6 100644 --- a/scripts/plot/draw/bar.m +++ b/scripts/plot/draw/bar.m @@ -292,24 +292,26 @@ %! close (hf); %! end_unwind_protect -## Style stacked (no difference for single group). +## Style "stacked" (no difference for single group). %!test -%! hf = figure ("visible", "off"); +%! hf1 = figure ("visible", "off"); +%! hf2 = figure ("visible", "off"); %! unwind_protect -%! hax = axes ("parent", hf); -%! hb = bar (hax, 2:4, "grouped"); -%! bardata1 = get (hb); -%! hl = bardata1.baseline; -%! baselinedata1 = get (hl); -%! hp = bardata1.children; -%! patchdata1 = get (hp); -%! -%! hb = bar (hax, 2:4, "stacked"); -%! bardata2 = get (hb); -%! hl = bardata2.baseline; -%! baselinedata2 = get (hl); -%! hp = bardata2.children; -%! patchdata2 = get (hp); +%! hax1 = axes ("parent", hf1); +%! hb1 = bar (hax1, 2:4, "grouped"); +%! bardata1 = get (hb1); +%! hl1 = bardata1.baseline; +%! baselinedata1 = get (hl1); +%! hp1 = bardata1.children; +%! patchdata1 = get (hp1); +%! +%! hax2 = axes ("parent", hf2); +%! hb2 = bar (hax2, 2:4, "stacked"); +%! bardata2 = get (hb2); +%! hl2 = bardata2.baseline; +%! baselinedata2 = get (hl2); +%! hp2 = bardata2.children; +%! patchdata2 = get (hp2); %! %! assert (bardata1.barlayout, "grouped"); %! assert (bardata2.barlayout, "stacked"); @@ -317,11 +319,16 @@ %! bardata1.barlayout = []; %! bardata1.baseline = []; %! bardata1.children = []; +%! bardata1.parent = []; %! %! bardata2.bargroup = []; %! bardata2.barlayout = []; %! bardata2.baseline = []; %! bardata2.children = []; +%! bardata2.parent = []; +%! +%! baselinedata1.parent = []; +%! baselinedata2.parent = []; %! %! patchdata1.parent = []; %! patchdata2.parent = []; @@ -331,7 +338,8 @@ %! assert (isequaln (patchdata1, patchdata2)); %! %! unwind_protect_cleanup -%! close (hf); +%! close (hf1); +%! close (hf2); %! end_unwind_protect ## Style "hist" @@ -627,7 +635,7 @@ ## Change to horizontal: -%!test <65671> # Baseline should change to horizontal with bars. +%!test <*65671> # Baseline should change to horizontal with bars. %! hf = figure ("visible", "off"); %! unwind_protect %! hax = axes ("parent", hf); @@ -661,7 +669,7 @@ %! close (hf); %! end_unwind_protect -%!test <65734> # Axis ticks after change to horizontal should match barh. +%!test <*65734> # Axis ticks after change to horizontal should match barh. %! hf = figure ("visible", "off"); %! unwind_protect %! hax = axes ("parent", hf); @@ -775,7 +783,7 @@ %! end_unwind_protect ## Updating base plot xdata. -%!test <65734> # changing xdata should update xlim/ticks for new locations. +%!test <*65734> # Changing xdata should update xlim/ticks for new locations. %! hf = figure ("visible", "off"); %! unwind_protect %! xd = [0.6, 1.6, 2.6; 0.6, 1.6, 2.6; 1.4, 2.4, 3.4; 1.4, 2.4, 3.4]; diff --git a/scripts/plot/draw/barh.m b/scripts/plot/draw/barh.m index 20f9895b75..d828e6f430 100644 --- a/scripts/plot/draw/barh.m +++ b/scripts/plot/draw/barh.m @@ -221,9 +221,9 @@ %! assert (bardata.ydata, [2; 3; 4]); %! %! assert (patchdata.type, "patch"); -%! assert (patchdata.ydata, [0.6, 1.6, 2.6; ... -%! 0.6, 1.6, 2.6; ... -%! 1.4, 2.4, 3.4; ... +%! assert (patchdata.ydata, [0.6, 1.6, 2.6; +%! 0.6, 1.6, 2.6; +%! 1.4, 2.4, 3.4; %! 1.4, 2.4, 3.4], eps); %! assert (patchdata.xdata, [0, 0, 0; 2:4; 2:4; 0, 0, 0]); %! assert (size (patchdata.faces), [3, 4]); @@ -235,7 +235,7 @@ %! end_unwind_protect ## Baseline must be vertical for barh. -%!test <65671> +%!test <*65671> %! hf = figure ("visible", "off"); %! unwind_protect %! hax = axes ("parent", hf); @@ -258,6 +258,7 @@ %! hf = figure ("visible", "off"); %! unwind_protect %! hax = axes ("parent", hf); +%! hb = barh (hax, 2:4); %! axesdata = get (hax); %! assert (axesdata.ylim, [0.5, 3.5]); %! assert (axesdata.ytick, 1:3); @@ -271,7 +272,7 @@ %! close (hf); %! end_unwind_protect -## Style stacked (no difference for single group). +## Style "stacked" (no difference for single group). %!test %! hf1 = figure ("visible", "off"); %! hf2 = figure ("visible", "off"); @@ -321,7 +322,7 @@ %! close (hf2); %! end_unwind_protect -## Style hist. +## Style "hist" %!test %! hf = figure ("visible", "off"); %! unwind_protect @@ -333,9 +334,9 @@ %! assert (! isfield (bardata, "barlayout")); %! assert (! isfield (bardata, "barwidth")); %! assert (bardata.type, "patch"); -%! assert (bardata.ydata, [0.5, 1.5, 2.5; ... -%! 0.5, 1.5, 2.5; ... -%! 1.5, 2.5, 3.5; ... +%! assert (bardata.ydata, [0.5, 1.5, 2.5; +%! 0.5, 1.5, 2.5; +%! 1.5, 2.5, 3.5; %! 1.5, 2.5, 3.5], eps); %! assert (bardata.xdata, [0, 0, 0; 2:4; 2:4; 0, 0, 0]); %! assert (size (bardata.faces), [3, 4]); @@ -345,7 +346,7 @@ %! close (hf); %! end_unwind_protect -## Style histc. +## Style "histc" %!test %! hf = figure ("visible", "off"); %! unwind_protect @@ -378,21 +379,21 @@ %! %! assert (numel (hb), 3); %! assert (numel (hp), 3); -%! assert (all (strcmp ({bardata.type}, 'hggroup'))); -%! assert (bardata(1).baseline, bardata(2).baseline); # Common baseline -%! assert (bardata(1).baseline, bardata(3).baseline); # Common baseline -%! assert (bardata(1).bargroup, bardata(2).bargroup); # Common hggroup -%! assert (bardata(1).bargroup, bardata(3).bargroup); # Common hggroup -%! assert (all (strcmp ({bardata.barlayout}, 'grouped'))); -%! assert (all (strcmp ({bardata.horizontal}, 'on'))); +%! assert (all (strcmp ({bardata.type}, "hggroup"))); +%! assert (bardata(1).baseline, bardata(2).baseline); # Common baseline +%! assert (bardata(1).baseline, bardata(3).baseline); # Common baseline +%! assert (bardata(1).bargroup, bardata(2).bargroup); # Common hggroup +%! assert (bardata(1).bargroup, bardata(3).bargroup); # Common hggroup +%! assert (all (strcmp ({bardata.barlayout}, "grouped"))); +%! assert (all (strcmp ({bardata.horizontal}, "on"))); %! assert ([bardata.basevalue], [0, 0, 0]); %! assert ([bardata.xdata], [1, 1, 1; 2, 2, 2]); %! assert ([bardata.ydata], [1, 2, 3; 4, 5, 6]); %! -%! assert (all (strcmp ({patchdata.type}, 'patch'))); -%! assert (patchdata(1).ydata, [2, 5; ... -%! 2, 5; ... -%! 64/25, 139/25; ... +%! assert (all (strcmp ({patchdata.type}, "patch"))); +%! assert (patchdata(1).ydata, [2, 5; +%! 2, 5; +%! 64/25, 139/25; %! 64/25, 139/25]/3, eps); %! assert (patchdata(1).xdata, [0, 0; 1, 4; 1, 4; 0, 0]); %! assert (size (patchdata(1).faces), [2, 4]); @@ -413,19 +414,19 @@ %! %! assert (numel (hb), 3); %! assert (numel (hp), 3); -%! assert (all (strcmp ({bardata.type}, 'hggroup'))); -%! assert (bardata(1).baseline, bardata(2).baseline); # Common baseline -%! assert (bardata(1).baseline, bardata(3).baseline); # Common baseline -%! assert (bardata(1).bargroup, bardata(2).bargroup); # Common hggroup -%! assert (bardata(1).bargroup, bardata(3).bargroup); # Common hggroup -%! assert (all (strcmp ({bardata.barlayout}, 'stacked'))); -%! assert (all (strcmp ({bardata.horizontal}, 'on'))); +%! assert (all (strcmp ({bardata.type}, "hggroup"))); +%! assert (bardata(1).baseline, bardata(2).baseline); # Common baseline +%! assert (bardata(1).baseline, bardata(3).baseline); # Common baseline +%! assert (bardata(1).bargroup, bardata(2).bargroup); # Common hggroup +%! assert (bardata(1).bargroup, bardata(3).bargroup); # Common hggroup +%! assert (all (strcmp ({bardata.barlayout}, "stacked"))); +%! assert (all (strcmp ({bardata.horizontal}, "on"))); %! %! assert ([bardata.basevalue], [0, 0, 0]); %! assert ([bardata.xdata], [1, 1, 1; 2, 2, 2]); %! assert ([bardata.ydata], [1, 2, 3; 4, 5, 6]); %! -%! assert (all (strcmp ({patchdata.type}, 'patch'))); +%! assert (all (strcmp ({patchdata.type}, "patch"))); %! assert (all (cellfun (@isequal, {patchdata.ydata}, ... %! {[0.6, 1.6; 0.6, 1.6; 1.4, 2.4; 1.4, 2.4]}))); %! assert (patchdata(1).xdata, [0, 0; 1, 4; 1, 4; 0, 0]); @@ -450,19 +451,19 @@ %! %! assert (numel (hb), 3); %! assert (numel (hp), 3); -%! assert (all (strcmp ({bardata.type}, 'hggroup'))); -%! assert (bardata(1).baseline, bardata(2).baseline); # Common baseline -%! assert (bardata(1).baseline, bardata(3).baseline); # Common baseline -%! assert (bardata(1).bargroup, bardata(2).bargroup); # Common hggroup -%! assert (bardata(1).bargroup, bardata(3).bargroup); # Common hggroup -%! assert (all (strcmp ({bardata.barlayout}, 'stacked'))); -%! assert (all (strcmp ({bardata.horizontal}, 'on'))); +%! assert (all (strcmp ({bardata.type}, "hggroup"))); +%! assert (bardata(1).baseline, bardata(2).baseline); # Common baseline +%! assert (bardata(1).baseline, bardata(3).baseline); # Common baseline +%! assert (bardata(1).bargroup, bardata(2).bargroup); # Common hggroup +%! assert (bardata(1).bargroup, bardata(3).bargroup); # Common hggroup +%! assert (all (strcmp ({bardata.barlayout}, "stacked"))); +%! assert (all (strcmp ({bardata.horizontal}, "on"))); %! %! assert ([bardata.basevalue], [0, 0, 0]); %! assert ([bardata.xdata], [1, 1, 1; 2, 2, 2]); %! assert ([bardata.ydata], [-2, 1, 3; 4, -5, 6]); %! -%! assert (all (strcmp ({patchdata.type}, 'patch'))); +%! assert (all (strcmp ({patchdata.type}, "patch"))); %! assert (all (cellfun (@isequal, {patchdata.ydata}, ... %! {[0.6, 1.6; 0.6, 1.6; 1.4, 2.4; 1.4, 2.4]}))); %! assert (patchdata(1).xdata, [0, 0; -2, 4; -2, 4; 0, 0]); @@ -476,8 +477,8 @@ %! end_unwind_protect ## Test plot property settings/updates -## Note - Not testing plot and children visibility settings to avoid creating -## test suite artifacts. +## Note: Not testing plot and children visibility settings to avoid creating +## test suite artifacts. ## Switch from grouped to stacked. %!test @@ -490,12 +491,12 @@ %! patchdata = get (hp); %! %! ## Verify base behavior. -%! assert (all (strcmp ({bardata.barlayout}, 'grouped'))); +%! assert (all (strcmp ({bardata.barlayout}, "grouped"))); %! assert ([bardata.xdata], [1, 1, 1; 2, 2, 2]); %! assert ([bardata.ydata], [1, 2, 3; 4, 5, 6]); -%! assert (patchdata(1).ydata, [2, 5; ... -%! 2, 5; ... -%! 64/25, 139/25; ... +%! assert (patchdata(1).ydata, [2, 5; +%! 2, 5; +%! 64/25, 139/25; %! 64/25, 139/25]/3, eps); %! assert (patchdata(1).xdata, [0, 0; 1, 4; 1, 4; 0, 0]); %! @@ -505,7 +506,7 @@ %! hp = [bardata.children](:); %! patchdata = get (hp); %! -%! assert (all (strcmp ({bardata.barlayout}, 'stacked'))); +%! assert (all (strcmp ({bardata.barlayout}, "stacked"))); %! assert ([bardata.xdata], [1, 1, 1; 2, 2, 2]); %! assert ([bardata.ydata], [1, 2, 3; 4, 5, 6]); %! assert (all (cellfun (@isequal, {patchdata.ydata}, ... @@ -518,7 +519,7 @@ %! end_unwind_protect ## Non-zero baseline -%!test <65671> +%!test <*65671> %! hf = figure ("visible", "off"); %! unwind_protect %! hax = axes ("parent", hf); @@ -536,9 +537,9 @@ %! assert (baselinedata.xdata, [3, 3]); %! assert (diff (baselinedata.ydata) > 0); %! -%! assert (patchdata.ydata, [0.6, 1.6, 2.6; ... -%! 0.6, 1.6, 2.6; ... -%! 1.4, 2.4, 3.4; ... +%! assert (patchdata.ydata, [0.6, 1.6, 2.6; +%! 0.6, 1.6, 2.6; +%! 1.4, 2.4, 3.4; %! 1.4, 2.4, 3.4], eps); %! assert (patchdata.xdata, [3, 3, 3; 2:4; 2:4; 3, 3, 3]); %! assert (size (patchdata.faces), [3, 4]); @@ -613,7 +614,7 @@ %! end_unwind_protect ## Change from horizontal: -%!test <65671> # Baseline should change to/from horizontal with bars. +%!test <*65671> # Baseline should change to/from horizontal with bars. %! hf = figure ("visible", "off"); %! unwind_protect %! hax = axes ("parent", hf); @@ -635,9 +636,9 @@ %! assert (baselinedata.ydata, [0, 0]); %! assert (diff (baselinedata.xdata) > 0); %! -%! assert (patchdata.xdata, [0.6, 1.6, 2.6; ... -%! 0.6, 1.6, 2.6; ... -%! 1.4, 2.4, 3.4; ... +%! assert (patchdata.xdata, [0.6, 1.6, 2.6; +%! 0.6, 1.6, 2.6; +%! 1.4, 2.4, 3.4; %! 1.4, 2.4, 3.4], eps); %! assert (patchdata.ydata, [0, 0, 0; 2:4; 2:4; 0, 0, 0]); %! assert (size (patchdata.faces), [3, 4]); @@ -647,7 +648,7 @@ %! close (hf); %! end_unwind_protect -%!test <65734> # Axis ticks after change from horizontal should match bar. +%!test <*65734> # Axis ticks after change from horizontal should match bar. %! hf = figure ("visible", "off"); %! unwind_protect %! hax = axes ("parent", hf); @@ -677,7 +678,7 @@ %! end_unwind_protect ## Change linear/log scale and move baseline/patch values if needed. -%!test <65671> +%!test <*65671> %! hf = figure ("visible", "off"); %! unwind_protect %! hax = axes ("parent", hf); @@ -713,7 +714,7 @@ %! end_unwind_protect ## Check baseline updating subfunctions -%!test <65671> # Baseline move or basevalue change: update line, bar, patch. +%!test <*65671> # Baseline move or basevalue change: update line, bar, patch. %! hf = figure ("visible", "off"); %! unwind_protect %! hax = axes ("parent", hf); @@ -730,9 +731,9 @@ %! assert (baselinedata.xdata, [0, 0]); %! assert (baselinedata.ydata, [0.5, 3.5], eps); %! assert (patchdata.xdata, [0, 0, 0; 2:4; 2:4; 0, 0, 0]); -%! assert (patchdata.ydata, [0.6, 1.6, 2.6; ... -%! 0.6, 1.6, 2.6; ... -%! 1.4, 2.4, 3.4; ... +%! assert (patchdata.ydata, [0.6, 1.6, 2.6; +%! 0.6, 1.6, 2.6; +%! 1.4, 2.4, 3.4; %! 1.4, 2.4, 3.4], eps); %! %! set (hax, "ylim", [0, 5]); # Change axes limits, verify baseline match. @@ -761,7 +762,7 @@ %! end_unwind_protect ## Updating base plot ydata. -%!test <65734> # changing xdata should update xlim/ticks for new locations. +%!test <*65734> # Changing xdata should update xlim/ticks for new locations. %! hf = figure ("visible", "off"); %! unwind_protect %! yd = [0.6, 1.6, 2.6; 0.6, 1.6, 2.6; 1.4, 2.4, 3.4; 1.4, 2.4, 3.4]; @@ -825,17 +826,17 @@ %! ## Verify base behavior. %! assert (get (hb, "barwidth"), 0.8, eps); %! assert (get (hb, "xdata"), [1:3]'); -%! assert (get (hp, "ydata"), [0.6, 1.6, 2.6; ... -%! 0.6, 1.6, 2.6; ... -%! 1.4, 2.4, 3.4; ... +%! assert (get (hp, "ydata"), [0.6, 1.6, 2.6; +%! 0.6, 1.6, 2.6; +%! 1.4, 2.4, 3.4; %! 1.4, 2.4, 3.4], eps); %! %! ## Verify changed behavior. %! set (hb, "barwidth", 0.5); %! assert (get (hb, "xdata"), [1:3]'); -%! assert (get (hp, "ydata"), [0.75, 1.75, 2.75; ... -%! 0.75, 1.75, 2.75; ... -%! 1.25, 2.25, 3.25; ... +%! assert (get (hp, "ydata"), [0.75, 1.75, 2.75; +%! 0.75, 1.75, 2.75; +%! 1.25, 2.25, 3.25; %! 1.25, 2.25, 3.25], eps); %! unwind_protect_cleanup %! close (hf); diff --git a/scripts/plot/draw/private/__bar__.m b/scripts/plot/draw/private/__bar__.m index 6911608196..a60fa0c947 100644 --- a/scripts/plot/draw/private/__bar__.m +++ b/scripts/plot/draw/private/__bar__.m @@ -128,7 +128,6 @@ endwhile ishist = islogical (histc); - ngrp = rows (x); if (isvector (y) && ngrp != rows (y)) @@ -225,32 +224,12 @@ endif unwind_protect hax = newplot (hax); - htmp = bars (hax, ishist, vertical, x, y, xb, yb, gwidth, group, have_line_spec, bv, newargs{:}); - if (! ishold ()) - if (numel (x(:,1)) <= 15 && all (x(:,1) == fix (x(:,1)))) - ## Set manual ticks, rather than relying on autoselection, - ## when ticks are a small number of integers. - if (vertical) - set (hax, "xtick", x(:,1)); - else - set (hax, "ytick", x(:,1)); - endif - endif - if (ishist) - set (hax, "climmode", "auto"); - else - ## Hack prevents xlim setting changes when basevalue changes. - if (vertical) - set (hax, "xlimmode", "manual"); - else - set (hax, "ylimmode", "manual"); - endif - endif - set (hax, "box", "on", "layer", "top"); + update_axes_limits (hax, x, vertical, ishist && histc); endif + unwind_protect_cleanup if (! isempty (oldfig)) set (0, "currentfigure", oldfig); @@ -271,7 +250,8 @@ endfunction -function hglist = bars (hax, ishist, vertical, x, y, xb, yb, width, group, have_color_spec, base_value, varargin) +function hglist = bars (hax, ishist, vertical, x, y, xb, yb, width, group, + have_color_spec, base_value, varargin) hglist = []; nbars = columns (y); @@ -295,8 +275,7 @@ hglist = [hglist; h]; endfor - - return; # return immediately, rest of function is for creating Bar object. + return; # return immediately, rest of function creates Bar object. endif ## Code to create hggroup Bar object @@ -308,14 +287,16 @@ if (vertical) if (! have_color_spec) color = __next_line_color__ (); - h = patch (hax, xb(:,:,i), yb(:,:,i), "FaceColor", color, "parent", hg); + h = patch (hax, xb(:,:,i), yb(:,:,i), "FaceColor", color, ... + "parent", hg); else h = patch (hax, xb(:,:,i), yb(:,:,i), "cdata", i, "parent", hg); endif else if (! have_color_spec) color = __next_line_color__ (); - h = patch (hax, yb(:,:,i), xb(:,:,i), "FaceColor", color, "parent", hg); + h = patch (hax, yb(:,:,i), xb(:,:,i), "FaceColor", color, ... + "parent", hg); else h = patch (hax, yb(:,:,i), xb(:,:,i), "cdata", i, "parent", hg); endif @@ -323,18 +304,30 @@ if (i == 1) ## Add baseline object the first time through loop - x_axis_range = get (hax, "xlim"); - h_baseline = __go_line__ (hax, "xdata", x_axis_range, - "ydata", [base_value, base_value], - "color", [0, 0, 0]); - set (h_baseline, "handlevisibility", "off", "xliminclude", "off", - "parent", get (hg, "parent")); + ## Undocumented x/yliminclude property prevents baseline from affecting + ## x/ylim perpendicular to bar direction, but x/ylim parallel to bar + ## direction must be sensitive to baseline position. + if (vertical) + x_axis_range = get (hax, "xlim"); + baseline = __go_line__ (hax, "xdata", x_axis_range, + "ydata", [base_value, base_value], + "color", [0, 0, 0]); + set (baseline, "handlevisibility", "off", "xliminclude", "off", + "parent", hax); + else + y_axis_range = get (hax, "ylim"); + baseline = __go_line__ (hax, "ydata", y_axis_range, + "xdata", [base_value, base_value], + "color", [0, 0, 0]); + set (baseline, "handlevisibility", "off", "yliminclude", "off", + "parent", hax); + endif endif ## Setup the hggroup and listeners addproperty ("showbaseline", hg, "radio", "{on}|off"); addproperty ("basevalue", hg, "data", base_value); - addproperty ("baseline", hg, "data", h_baseline); + addproperty ("baseline", hg, "data", baseline); addlistener (hg, "showbaseline", {@show_baseline, "showbl"}); addlistener (hg, "visible", {@show_baseline, "visib"}); @@ -346,6 +339,7 @@ else addproperty ("barlayout", hg, "radio", "{stacked}|grouped", "stacked"); endif + if (vertical) addproperty ("horizontal", hg, "radio", "on|{off}", "off"); else @@ -366,11 +360,7 @@ addlistener (hg, "linestyle", @update_props); addlistener (hg, "linewidth", @update_props); - if (isvector (x)) - addproperty ("xdata", hg, "data", x); - else - addproperty ("xdata", hg, "data", x(:, i)); - endif + addproperty ("xdata", hg, "data", x); addproperty ("ydata", hg, "data", y(:, i)); addlistener (hg, "xdata", @update_data); @@ -387,35 +377,57 @@ endif endfor - update_xlim (hax, []); + update_baseline_lim (hax, []); + ## 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, "xlim", @update_baseline_lim); addlistener (hax, "yscale", {@update_basevalue_logscale, hg}); - addlistener (h_baseline, "ydata", @update_baseline); - addlistener (h_baseline, "visible", @update_baseline); + addlistener (baseline, "ydata", @update_baseline); + + addlistener (hax, "ylim", @update_baseline_lim); + addlistener (hax, "xscale", {@update_basevalue_logscale, hg}); + addlistener (baseline, "xdata", @update_baseline); + + addlistener (baseline, "visible", @update_baseline); endfunction -function update_xlim (h, ~) +function update_baseline_lim (hax, ~) - kids = get (h, "children"); - xlim = get (h, "xlim"); + ## set baseline extents to match current axes limits + [kids, xlim, ylim] = get (hax, {"children", "xlim", "ylim"}){:}; for i = 1 : length (kids) obj = get (kids(i)); + if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline")) - if (any (get (obj.baseline, "xdata") != xlim)) - set (obj.baseline, "xdata", xlim); + + if (strcmp (obj.horizontal, "off")) # if (vertical) + if (any (get (obj.baseline, "xdata") != xlim)) + set (obj.baseline, "xdata", xlim); + endif + else + if (any (get (obj.baseline, "ydata") != ylim)) + set (obj.baseline, "ydata", ylim); + endif endif + endif endfor endfunction + function update_basevalue_logscale (hax, ~, hg) - if (strcmp (get (hax, "yscale"), "log")) + if (strcmp (get (hg, "horizontal"), "off")) + axisscale = "yscale"; + else + axisscale = "xscale"; + endif + + if (strcmp (get (hax, axisscale), "log")) warning ("off", "Octave:negative-data-log-axis", "local"); if (get (hg, "basevalue") == 0) set (hg, "basevalue", 1); @@ -428,35 +440,44 @@ function update_basevalue_logscale (hax, ~, hg) endfunction -function update_baseline (h, ~) - visible = get (h, "visible"); - ydata = get (h, "ydata")(1); +function update_baseline (hl, ~) + visible = get (hl, "visible"); ## Search axis for a bargroup that contains this baseline handle - kids = get (get (h, "parent"), "children"); + kids = get (get (hl, "parent"), "children"); for i = 1 : length (kids) obj = get (kids(i)); if (strcmp (obj.type, "hggroup") && isfield (obj, "baseline") - && obj.baseline == h) - set (obj.bargroup, "showbaseline", visible, "basevalue", ydata); + && obj.baseline == hl) + + if (strcmp (obj.horizontal, "off")) + data = get (hl, "ydata")(1); + else + data = get (hl, "xdata")(1); + endif + + set (obj.bargroup, "showbaseline", visible, "basevalue", data); break; + endif endfor endfunction -function show_baseline (h, ~, prop = "") + +function show_baseline (hg, ~, prop = "") + persistent recursion = false; ## Don't allow recursion if (! recursion) unwind_protect recursion = true; - hlist = get (h, "bargroup"); + hlist = get (hg, "bargroup"); if (strcmp (prop, "showbl")) - showbaseline = get (h, "showbaseline"); - hlist = hlist(hlist != h); # remove current handle being updated + showbaseline = get (hg, "showbaseline"); + hlist = hlist(hlist != hg); # remove current handle being updated set (hlist, "showbaseline", showbaseline); elseif (strcmp (prop, "visib")) showbaseline = "on"; @@ -464,7 +485,7 @@ function show_baseline (h, ~, prop = "") showbaseline = "off"; endif endif - set (get (h, "baseline"), "visible", showbaseline); + set (get (hg, "baseline"), "visible", showbaseline); unwind_protect_cleanup recursion = false; end_unwind_protect @@ -472,19 +493,25 @@ function show_baseline (h, ~, prop = "") endfunction -function move_baseline (h, ~) - persistent recursion = false; +function move_baseline (hg, ~) + + persistent recursion = false; ## Don't allow recursion if (! recursion) + recursion = true; unwind_protect - b0 = get (h, "basevalue"); - bl = get (h, "baseline"); - set (bl, "ydata", [b0, b0]); + [b0, bl] = get (hg, {"basevalue", "baseline"}){:}; + + if (strcmp (get (hg, "horizontal"), "off")) # if (vertical) + set (bl, "ydata", [b0, b0]); + else + set (bl, "xdata", [b0, b0]); + endif - if (strcmp (get (h, "barlayout"), "grouped")) - update_data (h); + if (strcmp (get (hg, "barlayout"), "grouped")) + update_data (hg); endif unwind_protect_cleanup recursion = false; @@ -493,21 +520,23 @@ function move_baseline (h, ~) endfunction -function update_props (h, ~) - kids = get (h, "children"); + +function update_props (hg, ~) + kids = get (hg, "children"); set (kids, {"edgecolor", "linewidth", "linestyle", "facecolor"}, - get (h, {"edgecolor", "linewidth", "linestyle", "facecolor"})); + get (hg, {"edgecolor", "linewidth", "linestyle", "facecolor"})); endfunction -function update_data (h, ~) - persistent recursion = false; +function update_data (hg, ~) + + persistent recursion = false; ## Don't allow recursion if (! recursion) unwind_protect recursion = true; - hlist = get (h, "bargroup"); - x = get (h, "xdata"); + hlist = get (hg, "bargroup"); + x = get (hg, "xdata"); if (! isvector (x)) x = x(:); endif @@ -520,10 +549,12 @@ function update_data (h, ~) y = ydat; endif - [xb, yb] = bar (x, y, get (h, "barwidth"), get (h, "barlayout"), - "basevalue", get (h, "basevalue")); + [b0, bl, bw, blo, horiz, hax] = get (hg, ... + {"basevalue", "baseline", "barwidth", ... + "barlayout", "horizontal", "parent"}){:}; + [xb, yb] = bar (x, y, bw, blo, "basevalue", b0); - vertical = strcmp (get (h, "horizontal"), "off"); + vertical = strcmp (horiz, "off"); for i = 1:columns (y) hp = get (hlist(i), "children"); if (vertical) @@ -532,6 +563,27 @@ function update_data (h, ~) set (hp, "xdata", yb(:,:,i), "ydata", xb(:,:,i)); endif endfor + + ## Update baseline properties affecting x/ylim + if (vertical) + set (bl, {"xliminclude", "yliminclude"}, {"off", "on"}); + set (bl, "ydata", [b0, b0]); + else + set (bl, {"xliminclude", "yliminclude"}, {"on", "off"}); + set (bl, "xdata", [b0, b0]); + endif + + if (! ishold ()) + update_axes_limits (hax, x, vertical, strcmpi (blo, "histc")); + endif + + ## Update baseline extents to x/ylim. + if (vertical) + set (bl, "xdata", get (hax, "xlim")); + else + set (bl, "ydata", get (hax, "ylim")); + endif + unwind_protect_cleanup recursion = false; end_unwind_protect @@ -539,25 +591,53 @@ function update_data (h, ~) endfunction -function update_group (h, ~) - persistent recursion = false; +function update_group (hg, ~) + + persistent recursion = false; ## Don't allow recursion if (! recursion) unwind_protect recursion = true; - hlist = get (h, "bargroup"); - barwidth = get (h, "barwidth"); - barlayout = get (h, "barlayout"); - horizontal = get (h, "horizontal"); + hlist = get (hg, "bargroup"); + barwidth = get (hg, "barwidth"); + barlayout = get (hg, "barlayout"); + horizontal = get (hg, "horizontal"); - hlist = hlist(hlist != h); # remove current handle being updated + hlist = hlist(hlist != hg); # remove current handle being updated set (hlist, "barwidth", barwidth, "barlayout", barlayout, "horizontal", horizontal); - update_data (h); + update_data (hg); unwind_protect_cleanup recursion = false; end_unwind_protect endif endfunction + + +function update_axes_limits (hax, x, vertical, ishistc) + + if (numel (x(:,1)) <= 15 && all (x(:,1) == fix (x(:,1)))) + ## Set manual ticks, rather than relying on autoselection, when ticks are + ## a small number of integers. + ## Then temporarily set to auto to reset limits around patch elements and + ## baseline component parallel to bars. + if (vertical) + set (hax, "xtick", x(:,1)); + set (hax, "xlimmode", "auto"); + set (hax, "ytickmode", "auto"); + else + set (hax, "ytick", x(:,1)); + set (hax, "ylimmode", "auto"); + set (hax, "xtickmode", "auto"); + endif + endif + + if (ishistc) + set (hax, "climmode", "auto"); + endif + + set (hax, "box", "on", "layer", "top"); + +endfunction diff --git a/src/mkoctfile.in.cc b/src/mkoctfile.in.cc index d047431401..63ad6d72f9 100644 --- a/src/mkoctfile.in.cc +++ b/src/mkoctfile.in.cc @@ -250,12 +250,6 @@ make_vars_map (bool link_stand_alone, bool verbose, bool debug) std::string DEFAULT_LDFLAGS; -#if (defined (OCTAVE_USE_WINDOWS_API) || defined (CROSS) || defined (OCTAVE_LINK_ALL_DEPS)) - // We'll be linking the files we compile with -loctinterp and -loctave, - // so we need to know where to find them. - DEFAULT_LDFLAGS += "-L" + quote_path (vars["OCTLIBDIR"]); -#endif - if (vars["LIBDIR"] != "/usr/lib") DEFAULT_LDFLAGS += " -L" + quote_path (vars["LIBDIR"]);