[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug with patch
From: |
Shai Ayal |
Subject: |
Re: Bug with patch |
Date: |
Tue, 9 Oct 2007 06:51:36 +0200 |
On 10/8/07, David Bateman <address@hidden> wrote:
> There is an issue with the patch command.. Firstly it should accept a
> handle as the first argument (consider the attached patch). However the
> more important issue is that it miss treats the case where more that a
> single patch is treated in one call to patch. Consider the code
>
> t = (1/16:1/8:1)'*2*pi;t2 = ((1/16:1/8:1)' + 1/32)*2*pi; x =sin(t); y =
> cos(t); x2 = sin(t2); y2=cos(t2); h = patch([x,x2],[y,y2],'r')
>
> The patches are drawn correctly, however the handle h that is returned
> is a handle to the last patch drawn and not a handle to a multi-element
> patch that includes all of the patches..
>
> Its easy enough to treat the data and get this part right. However,
> looking at the facecolor code I'm not sure what this was originally
> trying to achieve and so I don't see the fix for this immediately.
> Shai/Kai do you a what the facecolor code is trying to do and a way to
> fix it to accept the cdata for multiple facets at once correctly?
This is Kai's code, but I think he was trying to achieve the behaviour
documented in:
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/patch.html?cmdname=patch
under the section "Color Data Interpretation"
Shai
>
> D.
>
> *** ./scripts/plot/patch.m.orig22 2007-10-08 18:14:05.623299538 +0200
> --- ./scripts/plot/patch.m 2007-10-08 18:13:48.114126966 +0200
> ***************
> *** 21,26 ****
> --- 21,27 ----
> ## @deftypefn {Function File} {} patch ()
> ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{c})
> ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{c},
> @var{opts})
> + ## @deftypefnx {Function File} {} patch (@var{h}, @dots{})
> ## Create patch object from @var{x} and @var{y} with color @var{c} and
> ## insert in the current axes object. Return handle to patch object.
> ##
> ***************
> *** 33,41 ****
>
> function h = patch (varargin)
>
> ! ## make a default patch object, and make it the current axes for
> ! ## the current figure.
> ! tmp = __patch__ (gca (), varargin{:});
>
> if (nargout > 0)
> h = tmp;
> --- 34,54 ----
>
> function h = patch (varargin)
>
> ! if (isscalar (varargin{1}) && ishandle (varargin{1}))
> ! h = varargin {1};
> ! if (! strcmp (get (h, "type"), "axes"))
> ! error ("patch: expecting first argument to be an axes object");
> ! endif
> ! oldh = gca ();
> ! unwind_protect
> ! axes (h);
> ! tmp = __patch__ (h, varargin{:});
> ! unwind_protect_cleanup
> ! axes (oldh);
> ! end_unwind_protect
> ! else
> ! tmp = __patch__ (gca (), varargin{:});
> ! endif
>
> if (nargout > 0)
> h = tmp;
>
>