# HG changeset patch # User David Bateman # Date 1278526888 -7200 # Node ID 84c35a483d1f1b7a397c2d1e2fc130060a0aa0c8 # Parent 56982359802800e877d48411f7630d30450c4bda Support 'hold all' (Feature Request #30336) diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,13 @@ +2010-07-07 David Bateman + + * __next_line_color__.m: Allow conditional initialisation of the + color_rotation variable. + * __next_line_style__.m: Allow conditional initialisation of the + style_rotation variable. + * hold.m: Support "hold all". + * newplot.m: Conditionally initialisation the line style and color + based on the __hold_all__ axes property. + 2010-07-04 Soren Hauberg * polynomial/deconv.m: ensure that the orientation of the third diff --git a/scripts/plot/__next_line_color__.m b/scripts/plot/__next_line_color__.m --- a/scripts/plot/__next_line_color__.m +++ b/scripts/plot/__next_line_color__.m @@ -32,10 +32,12 @@ persistent color_index; if (nargin < 2) - if (nargin == 1 && reset) - color_rotation = get (gca (), "colororder"); - num_colors = rows (color_rotation); - color_index = 1; + if (nargin == 1) + if (reset || isempty (color_rotation)) + color_rotation = get (gca (), "colororder"); + num_colors = rows (color_rotation); + color_index = 1; + endif elseif (! isempty (color_rotation)) rgb = color_rotation(color_index,:); if (++color_index > num_colors) diff --git a/scripts/plot/__next_line_style__.m b/scripts/plot/__next_line_style__.m --- a/scripts/plot/__next_line_style__.m +++ b/scripts/plot/__next_line_style__.m @@ -38,7 +38,7 @@ elseif (++style_index > num_styles) style_index = 1; endif - elseif (reset) + elseif (reset || isempty (style_rotation)) style_rotation = strsplit (get (gca (), "linestyleorder"), "|"); num_styles = length (style_rotation); style_index = 1; diff --git a/scripts/plot/hold.m b/scripts/plot/hold.m --- a/scripts/plot/hold.m +++ b/scripts/plot/hold.m @@ -29,6 +29,11 @@ ## Retain plot data and settings so that subsequent plot commands are displayed ## on a single graph. ## +## @item hold all +## Retain plot line color, line style, data and settings so that subsequent +## plot commands are displayed on a single graph with the next line color and +## style. +## ## @item hold off ## Clear plot and restore default graphics settings before each new plot ## command. (default). @@ -57,6 +62,7 @@ nargs = numel (varargin); endif + hold_all = false; if (nargs == 0) turn_hold_off = ishold (ax); elseif (nargs == 1) @@ -64,6 +70,9 @@ if (ischar (state)) if (strcmpi (state, "off")) turn_hold_off = true; + elseif (strcmpi (state, "all")) + turn_hold_off = false; + hold_all = true; elseif (strcmpi (state, "on")) turn_hold_off = false; else @@ -80,6 +89,7 @@ set (ax, "nextplot", "add"); set (fig, "nextplot", "add"); endif + set (ax, "__hold_all__", hold_all); endfunction diff --git a/scripts/plot/newplot.m b/scripts/plot/newplot.m --- a/scripts/plot/newplot.m +++ b/scripts/plot/newplot.m @@ -26,8 +26,6 @@ function newplot () if (nargin == 0) - __next_line_color__ (true); - __next_line_style__ (true); cf = gcf (); fnp = get (cf, "nextplot"); switch (fnp) @@ -43,6 +41,13 @@ endswitch ca = gca (); anp = get (ca, "nextplot"); + if (strcmp (get (ca, "__hold_all__"), "off")) + __next_line_color__ (true); + __next_line_style__ (true); + else + __next_line_color__ (false); + __next_line_style__ (false); + endif switch (anp) case "new" case "add" diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2010-07-07 David Bateman + + * graphics.h.in (axes): Add hidden property __hold_all. + 2010-07-07 Jaroslav Hajek * ov-class.h (octave_class::map): Turn to octave_map. diff --git a/src/graphics.h.in b/src/graphics.h.in --- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -2993,6 +2993,7 @@ radio_property yaxislocation , "{left}|right|zero" radio_property xaxislocation , "{bottom}|top|zero" array_property view u , Matrix () + bool_property __hold_all__ h , "off" radio_property nextplot , "new|add|replacechildren|{replace}" array_property outerposition u , default_axes_outerposition () radio_property activepositionproperty , "{outerposition}|position"