bugGNU Octave - Bugs: bug #45593, Color problem with patch ()

 
 

bug #45593: Color problem with patch ()

Submitter:  Julien Bect <jbect>
Submitted:  Tue 21 Jul 2015 05:11:49 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 23 Jul 2015 07:55:52 PM UTC, comment #8: 

I changed Octave to pass all fields in the face/vertex structure through to the underlying patch command.  See http://hg.savannah.gnu.org/hgweb/octave/rev/85dcbed19753.  The change was made on the stable branch and will be part of the 4.0.1 bug fix release.

Rik <rik5>
Group administrator
Thu 23 Jul 2015 11:19:23 AM UTC, comment #7: 


> I notice that you are trying to set the facecolor property
> inside the structure. That syntax isn't accepted according
> to the Matlab documentation, but it might be undocumented
> behavior.


Hello Rik,

You right, this is undocumented behaviour. And the other syntaxes that you propose are ok.

However, since this undocumented behaviour was also supported by Octave 3.8.x, perhaps would it be better to keep supporting it if we can ? i.e., accept any valid property of a patch object as field in the structure ?

Concerning your Matlab question, I get the following with R2012b:


ans =

     0     0     0


ans =

     0     0     0


ans =

     0     1     0


The rectangles are black in the first two cases, and green in the thrid case.

Julien Bect <jbect>
Wed 22 Jul 2015 08:54:13 PM UTC, comment #6: 

@Julien: This doesn't seem as bad as I first thought.  The problem is that the 'facecolor' attribute is being set to [0 0 0] (black).  If you change the 'facecolor' attribute to 'flat' the correct coloring is restored.

There are still a number of questions however.  The test script uses the structure syntax for supplying the faces and vertices.


fv = [];
fv.vertices = coord;
fv.faces = connec;
fv.facecolor = 'flat';
fv.facevertexcdata = c;


I notice that you are trying to set the facecolor property inside the structure.  That syntax isn't accepted according to the Matlab documentation, but it might be undocumented behavior.


patch(FV) creates a patch using structure FV, which contains the fields vertices, faces, and optionally facevertexcdata. These fields correspond to the Vertices, Faces, and FaceVertexCData patch properties. Specifying only unique vertices and their connection matrix can reduce the size of the data for patches having many faces. For an example of how to specify patches with this method, see Specifying Patch Object Shapes.


Here are a couple examples of syntax that works in Octave:


hp = patch (fv);
set (hp, 'facecolor', 'flat');

patch ('faces', connec, 'vertices', coord, 'facevertexcdata', c, 'facecolor', 'flat')

patch (fv, 'facecolor', 'flat')


Do you have access to Matlab?  I'd like to try and see what is going on here.


script_patch_problem

close all;
hp = patch ('faces', connec, 'vertices', coord);
get (hp, 'facecolor')

close all;
hp = patch ('faces', connec, 'vertices', coord, 'facevertexcdata', c);
get (hp, 'facecolor')

close all;
fv.facecolor = 'g';
hp = patch (fv);
get (hp, 'facecolor')



Rik <rik5>
Group administrator
Tue 21 Jul 2015 08:17:03 AM UTC, comment #5: 

Thank you.

Julien Bect <jbect>
Tue 21 Jul 2015 08:07:08 AM UTC, comment #4: 

A new report was filed for the gnuplot issue.

Avinoam Kalma <avinoam>
Group Member
Tue 21 Jul 2015 06:51:49 AM UTC, comment #3: 

@Avinoam Kalm, Dan Sebald: this gnuplot error seems to be unrelated with the original purpose of this bug report.

Indeed, this error message disappears if you simply remove the unused third column in the coord matrix (see attached script).

And then gnuplot behaves exactly like Qt and FLTK: the rectangles have the correct size but not are all black.

Please keep this bug report focused on the patch/color issue, and open another bug report to discuss the issue about gnuplot and 3-D patches.

(file #34477)

Julien Bect <jbect>
Tue 21 Jul 2015 06:34:40 AM UTC, comment #2: 

The following code is what complains and the pm3d style of gnuplot is used:


               if (numel (xcol) > 3)
                 error ("__go_draw_axes__: gnuplot (as of v4.2) only supports 3-D filled triangular patches");
               else
                 if (isnan (data_3d_idx))
                   data_idx++;
                   data_3d_idx = data_idx;
                   is_image_data(data_idx) = false;
                   parametric(data_idx) = false;
                   have_cdata(data_idx) = true;
                   have_3d_patch(data_idx) = true;
                   withclause{data_3d_idx} = sprintf ("with pm3d");
                   usingclause{data_3d_idx} =  "using 1:2:3:4";
                   data{data_3d_idx} = [];
                 endif
                 local_idx = data_3d_idx;
                 ccdat = NaN;
               endif


If one were to write the above to use triangulation of polygons, it would be possible to use pm3d.  However, a more straightforward approach might be to use gnuplot's polygon object.  As an example:


set object 1 polygon from 2,2 to 3,2 to 3,3 to 2,3 to 2,2
set object 1 fc rgb "cyan" fillstyle solid 1.0 border lt -2
set xrange [0:10]
set yrange [0:10]
set zrange [0:10]
splot 1/0


Dan Sebald <sebald>
Tue 21 Jul 2015 05:25:12 AM UTC, comment #1: 

Using gnuplot as graphics_toolkit, I get


error: __go_draw_axes__: gnuplot (as of v4.2) only supports 3-D filled triangular patches
error: called from
    __go_draw_axes__ at line 671 column 18
    __go_draw_figure__ at line 172 column 17
    __gnuplot_drawnow__ at line 86 column 5


Avinoam Kalma <avinoam>
Group Member
Tue 21 Jul 2015 05:11:49 AM UTC, original submission:  

The attached script demonstrates a regression between Octave 3.8.2 and Octave 4.0.0 with the patch function.

The corrected behaviour (also observed in Matlab R2012b) is to produce a patch of color-filled rectangles. See patches_octave382_fltk.eps.

In Octave 4.0.0, both with Qt and FTLK as graphic toolkits, the rectangles are black. See patches_octave400_fltk.eps and patches_octave400_qt.eps.



Julien Bect <jbect>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #34477:  script_patch_problem_2.m added by jbect (693B - text/x-objcsrc)
file #34473:  script_patch_problem.m added by jbect (765B - text/x-objcsrc)
file #34474:  patches_octave382_fltk.eps added by jbect (11KiB - application/postscript)
file #34475:  patches_octave400_fltk.eps added by jbect (10KiB - application/postscript)
file #34476:  patches_octave400_qt.eps added by jbect (10KiB - application/postscript)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by sebald (Posted a comment)
  • -email is unavailable- added by avinoam (Posted a comment)
  • -email is unavailable- added by jbect (Submitted the item)
  • -email is unavailable- added by jbect
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-07-23 rik5 StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2015-07-22 rik5 StatusNone In Progress
    2015-07-21 jbect Attached File- Added script_patch_problem_2.m, #34477
    2015-07-21 jbect Attached File- Added script_patch_problem.m, #34473
        Attached File- Added patches_octave382_fltk.eps, #34474
        Attached File- Added patches_octave400_fltk.eps, #34475
        Attached File- Added patches_octave400_qt.eps, #34476
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code