Mercurial > hg > octave-max
changeset 7510:f3e6ada67d9e
improve handling line style for errorbar plots
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 21 Feb 2008 03:58:57 -0500 |
parents | e41d6aff83ea |
children | f028e7aa77a7 |
files | scripts/ChangeLog scripts/plot/__go_draw_axes__.m scripts/plot/errorbar.m |
diffstat | 3 files changed, 50 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,10 @@ +2008-02-21 John W. Eaton <jwe@octave.org> + + * plot/errorbar.m: If nargout > 0, return vector of handles to + line objects. + * plot/__go_draw_axes__.m: Improve handling of line style for + errorbar plots. + 2008-02-20 Marco Caliari <marco.caliari@univr.it> * specfun/legendre.m: Accept normalization options ("sch", "norm"),
--- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -397,16 +397,8 @@ tmp = undo_string_escapes (__maybe_munge_text__ (enhanced, obj, "keylabel", have_newer_gnuplot)); titlespec{data_idx} = strcat ("title \"", tmp, "\""); endif - [style, typ, with] = do_linestyle_command (obj, data_idx, - mono, plot_stream); usingclause{data_idx} = ""; - if (have_newer_gnuplot || isnan (typ)) - withclause{data_idx} = sprintf ("with %s linestyle %d", - style, data_idx); - else - withclause{data_idx} = sprintf ("with %s linetype %d", - style, typ); - endif + errbars = ""; if (nd == 3) xdat = obj.xdata(:); ydat = obj.ydata(:); @@ -464,11 +456,11 @@ endif data{data_idx} = [xdat, ydat, xlo, xhi, ylo, yhi]'; usingclause{data_idx} = "using ($1):($2):($3):($4):($5):($6)"; - withclause{data_idx} = "with xyerrorbars"; + errbars = "xyerrorbars"; else data{data_idx} = [xdat, ydat, ylo, yhi]'; usingclause{data_idx} = "using ($1):($2):($3):($4)"; - withclause{data_idx} = "with yerrorbars"; + errbars = "yerrorbars"; endif elseif (xerr) if (isempty (xldat)) @@ -483,13 +475,25 @@ endif data{data_idx} = [xdat, ydat, xlo, xhi]'; usingclause{data_idx} = "using ($1):($2):($3):($4)"; - withclause{data_idx} = "with xerrorbars"; + errbars = "xerrorbars"; else data{data_idx} = [xdat, ydat]'; usingclause{data_idx} = sprintf ("using ($1):($2) axes %s%s", xaxisloc_using, yaxisloc_using); endif endif + + [style, typ, with] = do_linestyle_command (obj, data_idx, mono, + plot_stream, errbars); + + if (have_newer_gnuplot || isnan (typ)) + withclause{data_idx} = sprintf ("with %s linestyle %d", + style, data_idx); + else + withclause{data_idx} = sprintf ("with %s linetype %d", + style, typ); + endif + if (! (have_newer_gnuplot || isempty (with))) if (isempty (withclause{data_idx})) withclause{data_idx} = sprintf ("with %s", with); @@ -1268,7 +1272,8 @@ endfunction -function [style, typ, with] = do_linestyle_command (obj, idx, mono, plot_stream) +function [style, typ, with] = do_linestyle_command (obj, idx, mono, + plot_stream, errbars) persistent have_newer_gnuplot ... = compare_versions (__gnuplot_version__ (), "4.0", ">"); @@ -1403,23 +1408,28 @@ pt = ""; endif - style = "lines"; - if (isempty (lt)) - if (! isempty (pt)) - style = "points"; + if (isempty (errbars)) + style = "lines"; + if (isempty (lt)) + if (! isempty (pt)) + style = "points"; + endif + elseif (! isempty (pt)) + style = "linespoints"; endif - elseif (! isempty (pt)) - style = "linespoints"; - endif - if (isfield (obj, "markersize")) - if (have_newer_gnuplot) - fprintf (plot_stream, " pointsize %f", obj.markersize); - else - if (! strcmpi (style, "lines")) - with = sprintf ("%s ps %f", with, obj.markersize); + if (isfield (obj, "markersize")) + if (have_newer_gnuplot) + fprintf (plot_stream, " pointsize %f", obj.markersize); + else + if (! strcmpi (style, "lines")) + with = sprintf ("%s ps %f", with, obj.markersize); + endif endif + found_style = true; endif + else + style = errbars; found_style = true; endif
--- a/scripts/plot/errorbar.m +++ b/scripts/plot/errorbar.m @@ -108,7 +108,7 @@ ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi> ## Keywords: errorbar, plotting -function errorbar (varargin) +function retval = errorbar (varargin) [h, varargin] = __plt_get_axis_arg__ ("errorbar", varargin{:}); @@ -116,7 +116,12 @@ unwind_protect axes (h); newplot (); - __errcomm__ ("errorbar", h, varargin{:}); + + tmp = __errcomm__ ("errorbar", h, varargin{:}); + + if (nargout > 0) + retval = tmp; + endif unwind_protect_cleanup axes (oldh); end_unwind_protect