axis tight fails for plots with more than one line
Ben Abbott
bpabbott at mac.com
Mon Jun 8 17:38:07 CDT 2009
On Jun 5, 2009, at 2:28 PM, Garrett Euler wrote:
> Bug report for Octave 3.2.0 configured for x86_64-unknown-linux-gnu
>
> Description:
> -----------
>
> * Using the command "axis tight" fails on plots with multiple lines.
> This is with Octave 3.2.0-rc7 (I believe this is the official
> release too). I have included a short test and a fix for the
> __get_tight_lims__ function in axis.m.
>
> __get_tight_lims__ (had it worked) also returned incorrect limits
> for plots with multiple lines (it used min(max()) instead of
> max(max()) ). This was fixed here too.
>
> Repeat-By:
> ---------
>
> * octave:1> plot(1:10)
> octave:2> hold on
> octave:3> plot(1:10)
> octave:4> axis tight
> error: cellfun: expecting all values to be scalars for UniformOutput
> = true
> error: evaluating argument list element number 1
> error: evaluating argument list element number 1
> error: called from:
> error: /usr/local/share/octave/3.2.0/m/plot/axis.m at line 301,
> column 15
> error: evaluating argument list element number 7
> error: evaluating argument list element number 1
> error: /usr/local/share/octave/3.2.0/m/plot/axis.m at line 313,
> column 3
> error: /usr/local/share/octave/3.2.0/m/plot/axis.m at line 200,
> column 1
> octave:4>
>
> Fix:
> ---
>
>
> * m/plot/axis.m: Fixed axis tight handling of plots with more
> than one line.
>
> --- /usr/local/share/octave/3.2.0/m/plot/axis-orig.m 2009-06-05
> 08:46:09.000000000 -0500
> +++ /usr/local/share/octave/3.2.0/m/plot/axis.m 2009-06-05
> 09:41:45.000000000 -0500
> @@ -298,8 +298,8 @@ function lims = __get_tight_lims__ (ca,
> else
> data = get (kids, strcat (ax, "data"));
> if (iscell (data))
> - lims(1) = min (cellfun (@min, data)(:));
> - lims(2) = min (cellfun (@max, data)(:));
> + lims =
> [min(cell2mat(cellfun(@min,data,'UniformOutput',false))) ...
> +
> max(cell2mat(cellfun(@max,data,'UniformOutput',false)))];
> else
> lims = [min(data(:)), max(data(:))];
> endif
I encountered an addiional problem when running the demos with your
solution.
I've pushed a chageset to the developers sources and modified the demo
for the "tight" option.
Ben
More information about the Bug-octave
mailing list