octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #34417] patch() does not process 'cdata' corre


From: Rik
Subject: [Octave-bug-tracker] [bug #34417] patch() does not process 'cdata' correctly
Date: Wed, 28 Sep 2011 16:24:17 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20100101 Firefox/5.0

URL:
  <http://savannah.gnu.org/bugs/?34417>

                 Summary: patch() does not process 'cdata' correctly
                 Project: GNU Octave
            Submitted by: rik5
            Submitted on: Wed 28 Sep 2011 09:24:16 AM PDT
                Category: Plotting
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: Patch Submitted
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: GNU/Linux

    _______________________________________________________

Details:

There are two ways of setting the color for patches.  The first method is to
create the patch with 'faces' and 'vertices' and use 'facevertexcdata'.  This
approach works.  The second method is to create the patch with x and y
vertices and use 'cdata' to set the color.  This approach seems to fail. 
Extensive reference on how to set the color of patch faces is given here
(http://www.mathworks.com/help/techdoc/ref/patch.html).

Sample code for method 1 (Working)


verts = [ 0 0
          1 0
          1 1
          0 1];
faces = [ 1 2 3
          1 3 4];
p = patch ('faces', faces, 'vertices', verts, 'facecolor', 'b');
# Produces two opposed triangles both colored blue
set (p, 'cdatamapping', 'direct', 'facecolor', 'flat', 'facevertexcdata', [1 ;
32])
# Changes color of triangles to blue and green
get (p, 'facevertexcdata')
ans =

    1
   32
get (p, 'cdata')
ans =

    1   32


Sample code for method 2 (Not Working)


clf;
x = [ 0 0
      1 1
      1 0 ];

y = [ 0 0
      0 1
      1 1 ];
p = patch (x, y, 'facecolor', 'b');
set (p, 'cdatamapping', 'direct', 'facecolor', 'flat', 'cdata', [1 32])
error: invalid value for array property "facevertexcdata"
error: called from:
error:  
/home/rik/wip/Projects_Mine/octave-dev/scripts/plot/private/__patch__.m at
line 315, column 7
error:  
/home/rik/wip/Projects_Mine/octave-dev/scripts/plot/private/__patch__.m at
line 299, column 3

get (p, 'cdata')
ans =

    1   32

get (p, 'facevertexcdata')
ans = [](1x0)


My hunch is that cdata and facevertexcdata are supposed to be transposes of
each other.  If one is a row vector the other needs to be a column vector.

The following change to __patch__.m at line 292 eliminates the error for me.


    #fvc = c(:).';
    fvc = c.';


I have attached a changeset which does just that.  If someone could verify
that this doesn't mess up anything else I think it should be adopted.




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Wed 28 Sep 2011 09:24:16 AM PDT  Name: patch.cdata  Size: 763B   By:
rik5

<http://savannah.gnu.org/bugs/download.php?file_id=24033>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?34417>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]