Skip to content

Commit

Permalink
maint: Merge stable to default.
Browse files Browse the repository at this point in the history
  • Loading branch information
NRJank committed Oct 16, 2024
2 parents 79bd745 + a045c40 commit ccbb17d
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 1 deletion.
4 changes: 3 additions & 1 deletion etc/NEWS.9.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ Summary of bugs fixed for version 9.3.0 (tbd):
patch and surface graphics objects (bug #66314).
- `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 (bug #65671).
properties to match redrawn plot (bug #65671).
- Tick mark labels are now correctly updated after changing x or y data for
`bar` and `barh` plots (bug #65734).

### GUI

Expand Down
61 changes: 61 additions & 0 deletions scripts/plot/draw/bar.m
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,67 @@
%! close (hf);
%! end_unwind_protect

## Ensure x tick labels are updated with xdata changes.
%!test <*65734>
%! hf = figure ("visible", "off");
%! unwind_protect
%! hax = axes ("parent", hf);
%! hb = bar (hax, 2:4);
%! hp = get (hb, "children");
%!
%! assert (get (hb, "xdata"), [1:3]');
%! assert (get (hax, {"xlim", "xtick","xticklabel"}), ...
%! {[0.5, 3.5], 1:3, {"1"; "2"; "3"}});
%! assert (get (hax, {"ylim", "ytick", "yticklabel"}), ...
%! {[0, 4], [0:4], {"0"; "1"; "2"; "3"; "4"}});
%!
%! set (hb, "xdata", [3:5]'); # column vector input.
%! assert (get (hax, {"xlim", "xtick","xticklabel"}), ...
%! {[2.5, 5.5], 3:5, {"3"; "4"; "5"}});
%! assert (get (hax, {"ylim", "ytick", "yticklabel"}), ...
%! {[0, 4], [0:4], {"0"; "1"; "2"; "3"; "4"}});
%!
%! set (hb, "xdata", [9:11]); # row vector input.
%! assert (get (hax, {"xlim", "xtick","xticklabel"}), ...
%! {[8.5, 11.5], 9:11, {"9"; "10"; "11"}});
%! assert (get (hax, {"ylim", "ytick", "yticklabel"}), ...
%! {[0, 4], [0:4], {"0"; "1"; "2"; "3"; "4"}});
%!
%! unwind_protect_cleanup
%! close (hf);
%! end_unwind_protect

#### Ensure y tick labels are updated with ydata changes.
%!test <*65734>
%! hf = figure ("visible", "off");
%! unwind_protect
%! hax = axes ("parent", hf);
%! hb = bar (hax, 2:4);
%! hp = get (hb, "children");
%!
%! assert (get (hb, "xdata"), [1:3]');
%! assert (get (hax, {"xlim", "xtick","xticklabel"}), ...
%! {[0.5, 3.5], 1:3, {"1"; "2"; "3"}});
%! assert (get (hax, {"ylim", "ytick", "yticklabel"}), ...
%! {[0, 4], [0:4], {"0"; "1"; "2"; "3"; "4"}});
%!
%! set (hb, "ydata", [5:7]'); # column vector input.
%! assert (get (hax, {"xlim", "xtick","xticklabel"}), ...
%! {[0.5, 3.5], 1:3, {"1"; "2"; "3"}});
%! assert (get (hax, {"ylim", "ytick", "yticklabel"}), ...
%! {[0, 7], [0:7], {"0"; "1"; "2"; "3"; "4"; "5"; "6"; "7"}});
%!
%! set (hb, "ydata", [-4:-2]); # row vector input.
%! assert (get (hax, {"xlim", "xtick","xticklabel"}), ...
%! {[0.5, 3.5], 1:3, {"1"; "2"; "3"}});
%! assert (get (hax, {"ylim", "ytick", "yticklabel"}), ...
%! {[-4, 0], [-4:0], {"-4"; "-3"; "-2"; "-1"; "0"}});
%!
%! unwind_protect_cleanup
%! close (hf);
%! end_unwind_protect


%% Test input validation
%!error <Invalid call> bar ()
%!error <Y must be numeric> bar ("foo")
Expand Down
60 changes: 60 additions & 0 deletions scripts/plot/draw/barh.m
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,66 @@
%! close (hf);
%! end_unwind_protect

## Ensure x tick labels are updated with xdata changes.
%!test <*65734>
%! hf = figure ("visible", "off");
%! unwind_protect
%! hax = axes ("parent", hf);
%! hb = barh (hax, 2:4);
%! hp = get (hb, "children");
%!
%! assert (get (hb, "xdata"), [1:3]');
%! assert (get (hax, {"xlim", "xtick","xticklabel"}), ...
%! {[0, 4], [0:4], {"0"; "1"; "2"; "3"; "4"}});
%! assert (get (hax, {"ylim", "ytick", "yticklabel"}), ...
%! {[0.5, 3.5], 1:3, {"1"; "2"; "3"}});
%!
%! set (hb, "xdata", [3:5]'); # column vector input.
%! assert (get (hax, {"xlim", "xtick","xticklabel"}), ...
%! {[0, 4], [0:4], {"0"; "1"; "2"; "3"; "4"}});
%! assert (get (hax, {"ylim", "ytick", "yticklabel"}), ...
%! {[2.5, 5.5], 3:5, {"3"; "4"; "5"}});
%!
%! set (hb, "xdata", [9:11]); # row vector input.
%! assert (get (hax, {"xlim", "xtick","xticklabel"}), ...
%! {[0, 4], [0:4], {"0"; "1"; "2"; "3"; "4"}});
%! assert (get (hax, {"ylim", "ytick", "yticklabel"}), ...
%! {[8.5, 11.5], 9:11, {"9"; "10"; "11"}});
%!
%! unwind_protect_cleanup
%! close (hf);
%! end_unwind_protect

#### Ensure y tick labels are updated with ydata changes.
%!test <*65734>
%! hf = figure ("visible", "off");
%! unwind_protect
%! hax = axes ("parent", hf);
%! hb = barh (hax, 2:4);
%! hp = get (hb, "children");
%!
%! assert (get (hb, "xdata"), [1:3]');
%! assert (get (hax, {"xlim", "xtick","xticklabel"}), ...
%! {[0, 4], [0:4], {"0"; "1"; "2"; "3"; "4"}});
%! assert (get (hax, {"ylim", "ytick", "yticklabel"}), ...
%! {[0.5, 3.5], 1:3, {"1"; "2"; "3"}});
%!
%! set (hb, "ydata", [5:7]'); # column vector input.
%! assert (get (hax, {"xlim", "xtick","xticklabel"}), ...
%! {[0, 7], [0:7], {"0"; "1"; "2"; "3"; "4"; "5"; "6"; "7"}});
%! assert (get (hax, {"ylim", "ytick", "yticklabel"}), ...
%! {[0.5, 3.5], 1:3, {"1"; "2"; "3"}});%!
%!
%! set (hb, "ydata", [-4:-2]); # row vector input.
%! assert (get (hax, {"xlim", "xtick","xticklabel"}), ...
%! {[-4, 0], [-4:0], {"-4"; "-3"; "-2"; "-1"; "0"}});
%! assert (get (hax, {"ylim", "ytick", "yticklabel"}), ...
%! {[0.5, 3.5], 1:3, {"1"; "2"; "3"}});
%!
%! unwind_protect_cleanup
%! close (hf);
%! end_unwind_protect


%% Test input validation
%!error <Invalid call> bar ()
Expand Down
8 changes: 8 additions & 0 deletions scripts/plot/draw/private/__bar__.m
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,14 @@ function update_axes_limits (hax, x, vertical, ishistc)
## a small number of integers.
## Then temporarily set to auto to reset limits around patch elements and
## baseline component parallel to bars.

## Vector x inputs to bar are forced to be column vectors. x inputs from
## set command may be forced to row vectors. Ensure column vector for
## bar tick processing. See bug #65734.
if (isrow (x))
x = x(:);
endif

if (vertical)
set (hax, "xtick", x(:,1));
set (hax, "xlimmode", "auto");
Expand Down

0 comments on commit ccbb17d

Please sign in to comment.