bugGNU Octave - Bugs: bug #48208, "markersize"...

 
 

bug #48208: "markersize" compatibility

Submitter:  Dmitri A. Sergatskov <dasergatskov>
Submitted:  Mon 13 Jun 2016 03:34:34 AM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Dmitri A. Sergatskov Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 20 Jun 2016 06:57:52 PM UTC, comment #10: 

I think it is worth running the examples from comment #5 to determine exact Matlab behavior.

I made the '.' marker one-third of the MarkerSize property for Matlab compatibility in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/da9127ba1e0a).  This applies only to the OpenGL toolkits, but apparently gnuplot was already doing this correctly.

Rik <rik5>
Group administrator
Mon 20 Jun 2016 04:58:56 PM UTC, comment #9: 

@Dmitri: You're right that it may be the OpenGL renderer.  Small markersizes do not display on my screen, but are present in the output if I use print.

Rik <rik5>
Group administrator
Wed 15 Jun 2016 06:45:14 PM UTC, comment #8: 


> At the moment,
> h = plot (0.5, 0.5, '.', 'markersize', 1)
> produces a blank plot.


Works for me.
Did you try to make a hardcopy or just looked at the screen?
It could be issue with renderer.
I noticed that on different hardware gl plots look different.

Dmitri.

Dmitri A. Sergatskov <dasergatskov>
Wed 15 Jun 2016 06:26:04 PM UTC, comment #7: 

@Dmitri: Good digging through the documentation to find that specification.  I think Octave must have it wrong then.  For a circle the calculation is sz/2 and for a dot we use sz/3.  The older Matlab docs suggest we should really be using


(sz/2) / 3


for the dot size.  I think we also need to specify a minimum for the computed size of at least one pixel.  At the moment,


h = plot (0.5, 0.5, '.', 'markersize', 1)


produces a blank plot.  I need to use


set (h, 'markersize', 2)


before I can see anything.  I would still be interested in the table of markersizes to see if they are using a different sizing algorithm for the smaller markersizes versus the large ones.

Rik <rik5>
Group administrator
Wed 15 Jun 2016 05:19:04 PM UTC, comment #6: 

(Somehow my comments did not show up -- sorry if this is a duplicate).

In older version of Matlab's doc they say explicitly that size of the dot is 1/3 of specified size. See e.g.:

http://www-rohan.sdsu.edu/doc/matlab/techdoc/ref/line_props.html

Dmitri A. Sergatskov <dasergatskov>
Wed 15 Jun 2016 04:33:57 PM UTC, comment #5: 

Thanks everyone for testing.  The supposed behavior for a primitive line object is found at http://www.mathworks.com/help/matlab/ref/primitiveline-properties.html.

I mispelled the attribute 'markeredgecolor' which is why this error resulted.


get (h, 'markeredegcolor') % What is default (blue, or something else)
Error using graph2d.lineseries/get
The name 'markeredegcolor' is not an accessible property for an instance of class
'lineseries'.


That's okay though.  I get the gist, which is that for '.' the 'Color' attribute is used, unless 'markeredgecolor' has been specified to a different value than 'auto'.  So Octave is okay in that respect.

But I don't understand the sizings.  According to the documentation the sizing is done in points (basically 1/72 of an inch).  So for a screen resolution of 90 ppi I would expect some relation to the quantity


pixel_size = marker_size (points) * 1 inch     * 90 pixels
                                    ------       ---------
                                    72 points       inch


In gl-render.cc I see the following code for the marker size.


  double sz = size * toolkit.get_screen_resolution () / 72.0;


and later


    case '.':
      {
        double ang_step = M_PI / 5;

        glBegin (GL_POLYGON);
        for (double ang = 0; ang < (2*M_PI); ang += ang_step)
          glVertex2d (sz*cos (ang)/3, sz*sin (ang)/3);
        glEnd ();
      }


But also,


    case 'o':
      {
        double ang_step = M_PI / 5;

        glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
        for (double ang = 0; ang < (2*M_PI); ang += ang_step)
          glVertex2d (sz*cos (ang)/2, sz*sin (ang)/2);
        glEnd ();
      }


So, for the 'o' marker everything makes sense.  The size (diameter) is determined in points.  And the draw routine uses diameter/2, or the radius, to construct the 'o'.  But the dot marker is special.  It is using diameter/3 for the radius.
@Lachlan: Could you run tests in Matlab to try and determine what is going on?  I think we need to construct a table of marker size versus resulting pixel size on screen.

Possible code, with measurement after each run:


h = plot (0.5, 0.5, '.k');
set (h, 'markersize', 0.5);
set (h, 'markersize', 1);
set (h, 'markersize', 2);
set (h, 'markersize', 3);
set (h, 'markersize', 4);
set (h, 'markersize', 5);
set (h, 'markersize', 6);   % This is the default
set (h, 'markersize', 8);
set (h, 'markersize', 12);
set (h, 'markersize', 16);
set (h, 'markersize', 20);
set (h, 'markersize', 24);
set (h, 'markersize', 32);
set (h, 'markersize', 36);
set (h, 'markersize', 48);
set (h, 'markersize', 72);


And then repeated with the 'o' marker.


h = plot (0.5, 0.5, 'ok');
set (h, 'markersize', 0.5);
set (h, 'markersize', 1);
set (h, 'markersize', 2);
set (h, 'markersize', 3);
set (h, 'markersize', 4);
set (h, 'markersize', 5);
set (h, 'markersize', 6);   % This is the default
set (h, 'markersize', 8);
set (h, 'markersize', 12);
set (h, 'markersize', 16);
set (h, 'markersize', 20);
set (h, 'markersize', 24);
set (h, 'markersize', 32);
set (h, 'markersize', 36);
set (h, 'markersize', 48);
set (h, 'markersize', 72);


At the large sizes, like 72, it is clear that Octave is actually drawing 10-sided decagons, rather than smooth circles.  Does Matlab do this to or do they scale the number of vertices in the OpenGL polygon to make it appear smooth at all sizes?

Rik <rik5>
Group administrator
Wed 15 Jun 2016 11:10:09 AM UTC, comment #4: 

I got

set (h, 'markeredgecolor', 'g') % does dot change to 'green'
 Yes.

The previous ones are the same.

 get (0, 'screenpixelsperinch') % Current resolution
 ans = 120

Anonymous
Wed 15 Jun 2016 07:36:14 AM UTC, comment #3: 


get (h, 'markersize')       % What is default 
  ans = 6

get (h, 'markerfacecolor')  % What is default (blue, or something else)
  ans = none

get (h, 'markeredegcolor')  % What is default (blue, or something else)
  Error using graph2d.lineseries/get
The name 'markeredegcolor' is not an accessible property for an instance of class
'lineseries'.

set (h, 'markerfacecolor', 'm') % does dot change to 'magenta'
  No

set (h, 'markeredgecolor', 'g') % does dot change to 'green'
  No

%% Secondary test for markersize compatibility.
get (0, 'screenpixelsperinch')  % Current resolution
  ans = 90

set (h, 'markersize', 4)   % what is size of marker in pixels on screen?
  one (Yes, one.)

set (h, 'markersize', 16)  % what is size of marker in pixels on screen?
  It looks like a 5x5 square with two extra pixels

set (h, 'markersize', 36)  % what is size of marker in pixels on screen?
  It looks like a circle of about 14 pixels diameter.

Lachlan Andrew <lachlan>
Tue 14 Jun 2016 03:56:26 PM UTC, comment #2: 

To be clear, can somebody run the following in Matlab and report back.


h = plot (1:3, '.b')
get (h, 'markersize')       % What is default
get (h, 'markerfacecolor')  % What is default (blue, or something else)
get (h, 'markeredegcolor')  % What is default (blue, or something else)
set (h, 'markerfacecolor', 'm') % does dot change to 'magenta'
set (h, 'markeredgecolor', 'g') % does dot change to 'green'

%% Secondary test for markersize compatibility.
get (0, 'screenpixelsperinch')  % Current resolution
set (h, 'markersize', 4)   % what is size of marker in pixels on screen?
set (h, 'markersize', 16)  % what is size of marker in pixels on screen?
set (h, 'markersize', 36)  % what is size of marker in pixels on screen?


I'll re-post to the Octave-Maintainer's list.

Rik <rik5>
Group administrator
Mon 13 Jun 2016 04:37:16 AM UTC, comment #1: 

The issue is particular to the dot '.' marker.  Try using a different marker to see it working.


h = plot (1:10, 'dy');        % yellow diamonds
set (h, 'markersize', 24);    % big yellow diamonds
set (h, 'linewidth', 6);      % big, thick outlined yellow diamonds
set (h, 'markeredgecolor', 'k');  % big, thick outlined black diamonds
set (h, 'markerfacecolor', 'm');  % big, thick outline black diamonds, magenta insides
set (h, 'marker', '.');       % Now, black circles
set (h, 'marker', 'p');       % Pentagrams, with black outline and magenta insides.


I know there is special code in gl-render.cc for the '.' marker.  How does Matlab handle this?  Is '.', really equivalent to a circle (marker 'o') but with a reduced radius?  We need to know what behavior we should be aiming for.

Rik <rik5>
Group administrator
Mon 13 Jun 2016 03:34:34 AM UTC, original submission:  

plot(randn(3), ".y", "markersize", 24, "markeredgecolor", "k")

makes symbol color black (rather than making black border).

(both dev and 4.0.2 are affected)

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by lachlan (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by dasergatskov (Submitted the item)
  •  

    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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-11-03 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2016-06-15 rik5 Item GroupInaccurate Result Matlab Compatibility
        Summary&quot;markeredgecolor&quot; changes symbol color instead when symbol is '.' "markersize" compatibility
    2016-06-13 rik5 StatusNone Confirmed
        Summary&quot;markeredgecolor&quot; changes symbol color instead "markeredgecolor" changes symbol color instead when symbol is '.'

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code