Mercurial > jwe > octave
changeset 29135:8bb14f4979ca
Use colors from axes' "ColorOrder" property for bar charts for Matlab compatibility (bug #59589).
* NEWS: Announce change to bar, barh, and hist functions.
* bar.m, hist.m: Update documentation to reference colors are now from
"ColorOrder" property.
* __bar__.m: Replace previous color-setting code with call to function
__next_line_color().
author | Rik <rik@octave.org> |
---|---|
date | Wed, 02 Dec 2020 11:47:38 -0800 |
parents | 3b1d005aabbf |
children | 77ba9dfe5b29 |
files | NEWS scripts/plot/draw/bar.m scripts/plot/draw/hist.m scripts/plot/draw/private/__bar__.m |
diffstat | 4 files changed, 14 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Wed Dec 02 20:36:20 2020 +0100 +++ b/NEWS Wed Dec 02 11:47:38 2020 -0800 @@ -142,7 +142,7 @@ `"FaceColor"`, now accept HTML specifications. An HTML specification is a string that begins with the character '#' and is followed by either 3 or 6 hexadecimal digits. For example, magenta which is 100% red and -blue values can specified by `"#FF00FF"` or `"#F0F"`. +blue values can specified by `"#FF00FF"` or `"#F0F"`. - `uicontrol` objects now fully implement the `"Off"` and `"Inactive"` values of the `"Enable"` property. When the value is `"Off"`, no @@ -164,6 +164,10 @@ Previously the negative bars could overlap positive bars depending on drawing order. +- The functions `bar`, `barh`, and `hist` now use colors from the +`"ColorOrder"` axes property rather than the `"Colormap"` figure +property. + - The function `saveas` now defaults to saving in Octave figure format (.ofig) rather than PDF (.pdf).
--- a/scripts/plot/draw/bar.m Wed Dec 02 20:36:20 2020 +0100 +++ b/scripts/plot/draw/bar.m Wed Dec 02 11:47:38 2020 -0800 @@ -94,18 +94,9 @@ ## @end example ## ## @noindent -## The color of the bars is taken from the figure's colormap, such that -## -## @example -## @group -## bar (rand (10, 3)); -## colormap (summer (64)); -## @end group -## @end example -## -## @noindent -## will change the colors used for the bars. The color of bars can also be set -## manually using the @qcode{"facecolor"} property as shown below. +## The default color for bars is taken from the axes' @qcode{"ColorOrder"} +## property. The color of bars can also be set manually using the +## @qcode{"facecolor"} property as shown below. ## ## @example ## @group
--- a/scripts/plot/draw/hist.m Wed Dec 02 20:36:20 2020 +0100 +++ b/scripts/plot/draw/hist.m Wed Dec 02 11:47:38 2020 -0800 @@ -61,16 +61,9 @@ ## @end example ## ## @noindent -## The histogram's colors also depend upon the current colormap. -## -## @example -## @group -## hist (rand (10, 3)); -## colormap (summer ()); -## @end group -## @end example -## ## The full list of patch properties is documented at @ref{Patch Properties}. +## If not specified, the default colors for the histogram are taken from the +## axes' @qcode{"ColorOrder"} property. ## ## If the first argument @var{hax} is an axes handle, then plot into this axes, ## rather than the current axes returned by @code{gca}.
--- a/scripts/plot/draw/private/__bar__.m Wed Dec 02 20:36:20 2020 +0100 +++ b/scripts/plot/draw/private/__bar__.m Wed Dec 02 11:47:38 2020 -0800 @@ -276,25 +276,15 @@ if (vertical) if (! have_color_spec) - if (nbars == 1) - lev = clim(1); - else - lev = (i - 1) * (clim(2) - clim(1)) / (nbars - 1) - clim(1); - endif - h = patch (hax, xb(:,:,i), yb(:,:,i), - "FaceColor", "flat", "cdata", lev, "parent", hg); + color = __next_line_color__ (); + h = patch (hax, xb(:,:,i), yb(:,:,i), "FaceColor", color, "parent", hg); else h = patch (hax, xb(:,:,i), yb(:,:,i), "parent", hg); endif else if (! have_color_spec) - if (nbars == 1) - lev = clim(1); - else - lev = (i - 1) * (clim(2) - clim(1)) / (nbars - 1) - clim(1); - endif - h = patch (hax, yb(:,:,i), xb(:,:,i), - "FaceColor", "flat", "cdata", lev, "parent", hg); + color = __next_line_color__ (); + h = patch (hax, yb(:,:,i), xb(:,:,i), "FaceColor", color, "parent", hg); else h = patch (hax, yb(:,:,i), xb(:,:,i), "parent", hg); endif