bugGNU Octave - Bugs: bug #48401, gnuplot gridlinestyle property...

 
 

bug #48401: gnuplot gridlinestyle property overrides minorgridlinestyle propery

Submitter:  Vic Norton <vicnorton>
Submitted:  Mon 04 Jul 2016 09:09:42 PM UTC
   
 
Category:  Plotting with gnuplot Severity:  2 - Minor
Priority:  3 - Low Item Group:  None
Status:  Fixed Assigned to:  None
Originator Name:  Vic Norton Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 07 Jul 2016 05:10:43 AM UTC, comment #14: 

Matlab apparently changed their defaults for grid lines when they moved to Handle Graphics 2 and started using the alpha channel on grid lines.  I updated Octave to follow Matlab and use '-' as the default for gridlinestyle and ':' for minorgridlinestyle.  See http://hg.savannah.gnu.org/hgweb/octave/rev/05ad23810150.

I reversed the interpretation of the alpha property as you suggested in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/6f10765eca35).

The gridlines now seem to be okay, a little dim, but okay.

Rik <rik5>
Group administrator
Wed 06 Jul 2016 11:11:14 PM UTC, comment #13: 

I saw that Matlab called this "transparency" but didn't see the description of which extreme is what.  I just assumed a positive correlation between the number and "transparency".  But I suppose the 0.15 default makes more sense when viewed as being nearer to transparent for a grid line.

It's a simple change of


-      alphastr = sprintf ("%02x", round (255*obj.alpha));
+      alphastr = sprintf ("%02x", round (255*(1-obj.alpha)));


and works as expected.

However, there is a problem here, and this may have been what confused me.  With these default property settings:


    gridalpha =  0.15000
    gridcolor =

       0.15000   0.15000   0.15000

    gridlinestyle = :



    minorgridalpha =  0.25000
    minorgridcolor =

       0.10000   0.10000   0.10000

    minorgridlinestyle = :


the grid lines (major or minor) aren't visible.  If the gridlinestyle is '-', i.e., solid, then the alpha/color combination works OK.  Should that be the default linestyle for "grid on"?  Dots (':') is OK when the lines are nearer to opaque.

Another aspect of this is the difference between gnuplot (alpha implemented) and qt/fltk (no alpha implemented).  Compare the following:


for tk = {'gnuplot', 'qt', 'fltk'}
  graphics_toolkit (tk{});
  figure;
  plot (1:10); grid on;
  set(gca, 'gridlinestyle', '-');
endfor


Even though qt/fltk can't do true alpha blending, perhaps it should simply multiply the grid color channels by 1-alpha to get something close to the same affect as alpha blending.

(file #37742)

Dan Sebald <sebald>
Wed 06 Jul 2016 10:14:20 PM UTC, comment #12: 

@Dan: I pushed the change for polar plots here (http://hg.savannah.gnu.org/hgweb/octave/rev/eb751495ba43).

Could you take a look at the alpha mode?  According to Matlab


GridAlpha — Grid-line transparency
0.15 (default) | value in the range [0,1]

Grid-line transparency, specified as a value in the range [0,1]. A value of 1 means opaque and a value of 0 means completely transparent.


I think it is currently backwards where 1 is completely transparent and 0 is completely opaque.

Rik <rik5>
Group administrator
Wed 06 Jul 2016 08:14:16 PM UTC, comment #11: 

OK, thanks.  Attached is a small oversight I noticed when attempting "demo polar", i.e., axis_idx doesn't exist if there was no axis drawn.


(file #37739)

Dan Sebald <sebald>
Wed 06 Jul 2016 05:21:34 PM UTC, comment #10: 

I cleaned up the patch a bit.  I used "endif" rather than "end" and "strcmp" instead of "strcmpi".  Also, I found another case when the grid lines are not visible: gridcolor = "none".  I added a check for that and pushed everything here (http://hg.savannah.gnu.org/hgweb/octave/rev/1a8e2a0251c3).

Seems everything is okay now, closing report.

Rik <rik5>
Group administrator
Wed 06 Jul 2016 08:30:56 AM UTC, comment #9: 

So many variations...  An updated patch is attached, fairly straightforward.

To test the alpha blending, try something like:


plot (0:10); grid on; grid minor on;
set(gca, 'gridcolor', 'red', 'gridalpha', 0.5, 'minorgridcolor', 'green', 'minorgridalpha', 0.8, 'minorgridlinestyle', '-');
set(gca, 'gridcolor', 'red', 'gridalpha', 0.5, 'minorgridcolor', 'green', 'minorgridalpha', 0.8, 'minorgridlinestyle', 'none');


(The red/green combo makes me think of graph paper from way too far back to mention.)  As for alpha blending, experiment with different values of alpha and it become apparent it is working.  The grid lines could also be achieved by setting the color (while alpha is 0), but I think the difference with alpha blending is that the point where the grids and data curve intersect are a blend rather than one color or the other.


(file #37728)

Dan Sebald <sebald>
Tue 05 Jul 2016 09:12:16 PM UTC, comment #8: 

@Dan: This works fine for minor grids.  One remaining difference is that I can set a linestyle of "none" for major/minor grids with the OpenGL toolkits and this effectively hides that particular grid, even though it is "on".

Is there a simple way to check for "none" and not draw the grid?

Transparency isn't implemented at all in the OpenGL toolkits (the interface to OpenGL hasn't been written; OpenGL certainly supports it).  If it's easy to add then it makes sense to correct that incompatibility with Matlab as well for the gnuplot toolkit.

The "layer" property determines whether the axes object is on top or below the other graphic objects.

Rik <rik5>
Group administrator
Tue 05 Jul 2016 07:53:47 PM UTC, comment #7: 

OK, additional patch attached for minor grid lines.  Note that the command should be


set (gca, "minorgridcolor", "m")


i.e., axis not figure.

Let me know what you think of the minor grid lines.  They look fine, but perhaps not as nice as for 'qt' toolkit.  Those could be tweaked.

It looks like right now properties 'gridalphamode' and 'gridalpha' don't do anything in any of the toolkits.  I think that could be used in gnuplot just by changing "rgb" option to "rgba" option.  Is it supposed to be alpha blending when the grid lies at the front of the view?


(file #37725)

Dan Sebald <sebald>
Tue 05 Jul 2016 06:59:05 PM UTC, comment #6: 

@Dan: Works for me.  I pushed your cset here (http://hg.savannah.gnu.org/hgweb/octave/rev/79e7a6fc524d).

I noticed that 'gridlinestyle' and 'gridcolor' override the corresponding minorgridXXX properties.  I'm re-titling the bug to reflect that, but this is pretty minor stuff.

Steps to reproduce:


graphics_toolkit gnuplot
plot (1:10);
grid on
grid minor on


At this point, gridlinestyle has been changed to '-' and minorgridlinestyle is still at ':'.  You can see what it is supposed to look like by doing


graphics_toolkit (1, "qt")


Also try,


set (gcf, "minorgridcolor", "m")


But this has no effect.

Rik <rik5>
Group administrator
Tue 05 Jul 2016 06:08:02 PM UTC, comment #5: 

Give the attached patch a try.  gnuplot doesn't have dashtype for "set grid", but I managed to make it work by using a "linetype" definition.  (I'll send a note to gnuplot about that oversight.)  After your test example, try something like:

set(gca, 'gridlinestyle', ':', 'gridcolor', [0.1 0.5 0.1])

Also in the patch I add an extra conditional to get rid of some redundant lines of gnuplot code that set the characteristics for a non-existent point style.  There is actually more of this sort of redundant code if one sets points without lines.  The whole do_linestyle_command() could be reworked.  I began down that path but found the "found_style" and so many conditions to be confusing.

(file #37723)

Dan Sebald <sebald>
Tue 05 Jul 2016 04:41:06 AM UTC, comment #4: 

For gnuplot 4 or lower. no unified treatments dash or dotted lines for all terminals exist. I suspect that it is reason why the functionality is not supported for gnuplot graphics toolkit.

On the gnuplot ver. 5, unified treatments dash or dotted lines are implemented and thus the functionality mentioned here can be implemented.

But this is only possible when gnuplot version is 5.

Tatsuro MATSUOKA <tmacchant>
Tue 05 Jul 2016 04:06:54 AM UTC, comment #3: 

This doesn't work in 3.8.2 either.  I suspect that the functionality was never programmed into the Octave/gnuplot interface.

Rik <rik5>
Group administrator
Tue 05 Jul 2016 03:57:54 AM UTC, comment #2: 

I have built octave-4.1.0+ (revision 22035:634fbedbfb5b) on Ubuntu 14.04 amd and also confirmed the same results.
The value "Release" can be "dev".

Tatsuro MATSUOKA <tmacchant>
Tue 05 Jul 2016 12:01:06 AM UTC, comment #1: 

I have confirmed issue on native windows (4.0.3), cygwin (4.0.1) and linux (4.0.3). (Windows 10 and Ubuntu).
Therefore  "Operating System" should be "any".

Tatsuro MATSUOKA <tmacchant>
Mon 04 Jul 2016 09:09:42 PM UTC, original submission:  

+verbaitim+
% gnuplot_gridline_problem.m
%   octave> set(gca, "gridlinestyle")
%   [ - | -- | -. | {:} | none ]
%
%   When "xgrid" or "ygrid" is on
%   all options are available to "qt" but
%   every option produces ":" gridlines with "gnuplot"
graphics_toolkit("gnuplot");
% graphics_toolkit('qt');  % uncomment for correct results
x = 0 : 0.1 : 3.5;
y = sin(x);
close all;
figure;
plot(x, y);
axis([0, 3.5, 0, 1.5], "equal");
set(gca, "xgrid", "on", "ygrid", "on", ...
  "gridlinestyle", "-", ...
  "linewidth", 1, ...
  "xtick", [0 : 0.5 : 3.5], ...
  "ytick", [0 : 0.5 : 1.5] ...
);
printf("gridlinestyle: %s\n", get(gca, "gridlinestyle"));
-verbatim-

Vic Norton <vicnorton>

 

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

Attach Files:
   
   
Comment:
   

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by sebald (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by tmacchant (Posted a comment)
  • -email is unavailable- added by vicnorton (Submitted the item)
  • -email is unavailable- added by vicnorton
  •  

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

    Date Changed by Updated Field Previous Value => Replaced by
    2016-07-06 sebald Attached File- Added octave-gnuplot_invert_alpha-bug48401-djs2016jul06.patch, #37742
    2016-07-06 sebald Attached File- Added octave-gnuplot_grid_idx-bug48401-djs2016jul06.patch, #37739
    2016-07-06 rik5 Open/ClosedOpen Closed
    2016-07-06 rik5 StatusConfirmed Fixed
    2016-07-06 sebald Attached File- Added octave-gnuplot_minorgridlines-bug48401-djs2016jul06.patch, #37728
    2016-07-05 sebald Attached File- Added octave-gnuplot_minorgridlines-bug48401-djs2016jul05.patch, #37725
    2016-07-05 rik5 SummaryGnuplot produces only &quot;:&quot; gridlines gnuplot gridlinestyle property overrides minorgridlinestyle propery
    2016-07-05 sebald Attached File- Added octave-gnuplot_gridlines-bug48401-djs2016jul05.patch, #37723
    2016-07-05 mtmiller Release4.0.3 dev
    2016-07-05 rik5 Carbon-Copy- Added sebald
    2016-07-05 mtmiller Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        Release4.0.2 4.0.3
    2016-07-05 mtmiller StatusNone Confirmed
        Operating SystemMac OS Any
    2016-07-04 vicnorton Carbon-Copy- Added vicnorton

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code