bugGNU Octave - Bugs: bug #46886, linetype not respected across...

 
 

bug #46886: linetype not respected across gnuplot terminals

Submitter:  Ben Abbott <bpabbott>
Submitted:  Wed 13 Jan 2016 12:38:00 AM UTC
   
 
Category:  Plotting with gnuplot Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Ben Abbott 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 10 Mar 2016 01:46:50 AM UTC, comment #12: 

Rik,

I've pushed two changesets. I'll work on restoring support for gnuplot 4.6.x as time permits.

Ben Abbott <bpabbott>
Group Member
Thu 10 Mar 2016 12:53:25 AM UTC, comment #11: 

Rik, of course my changeset only addresses dashtypes for gnuplot 5.

I'm worried that we have introduced many bugs for gnuplot 4.6.x.

I'll work on testing and fixing as time permits. I'll first have to manage an install of gnuplot 4.6.x.

Ben Abbott <bpabbott>
Group Member
Wed 09 Mar 2016 11:41:16 PM UTC, comment #10: 

Ben, overall the changeset looks good.  Here is my modified script that I used to test your patch:


1;  # make this a script, not a function m-file

function do_plot (term)

  persistent x y
  if (isempty (x))
    rand ("state", 2);
    x = 1:4;
    y = rand (4);
  endif

  setenv ("GNUTERM", term);
  h = plot (x, y(1,:), "-",
            x, y(2,:), "--",
            x, y(3,:), "-.",
            x, y(4,:), ":");
  set (h, "linewidth", 2);
  drawnow ();
  title (term);

endfunction

graphics_toolkit gnuplot

if (ismac)
  figure (1);
  do_plot aqua
endif
figure (2);
do_plot x11
figure (3);
do_plot qt
figure (4);
do_plot wxt


I added a title() call so that I could quickly see which terminal was producing which set of lines.  Under gnuplot 5, they all seem to look more or less the same.  Under gnuplot 4.6.6 all of the lines are solid.  This is unrelated to your patch.  Apparently Octave has lost the ability to plot different line types when the version is less than 5.

I would say go ahead and commit it.

Also, I tried running some of the graphic demos under gnuplot and I'm getting different results than qt or fltk.  A while back we had a test script that ran all the demos under gnuplot, fltk, qt, and matlab.  It seems like it is time to dust that off and run it again.

The first thing I see is that 'shading interp' seems to be broken on gnuplot.  Also, when I run 'demo ("contour3", 1)' I get this


error: 'dataidx' undefined near line 1228 column 49
error: called from
    __gnuplot_draw_axes__ at line 1228 column 35
    __gnuplot_draw_figure__ at line 172 column 17
    __gnuplot_drawnow__ at line 86 column 5


All of this could go under a new bug report if you like.

Rik <rik5>
Group administrator
Wed 09 Mar 2016 12:58:56 PM UTC, comment #9: 

Rik,

Have you tried different terminal types with 2D plots? Below is a script that works for me. You'll need to delete "aqua".


1;

function do_plot (term)
  if (nargin < 1)
    term = "aqua";
  endif
  setenv ("GNUTERM", term);
  persistent x y
  if (isempty (x))
    x = 1:4;
    y = rand (4);
  endif
  h = plot (x, y(1,:), "-", ...
            x, y(2,:), "--", ...
            x, y(3,:), "-.", ...
            x, y(4,:), ":");
  set (h, "linewidth", 2);
  drawnow ()
end

graphics_toolkit gnuplot

figure (1)
do_plot aqua
figure (2)
do_plot x11
figure (3)
do_plot qt
figure (4)
do_plot wxt


I no longer have a gnuplot 4.6 to run. For gnuplot 5, this produces different linestyles for the terminals. However, I have a patch that fixes that (it is attached).

Sorry for cross-posting on the bug reports, but I posted to the wrong one first.

(file #36580)

Ben Abbott <bpabbott>
Group Member
Mon 29 Feb 2016 03:43:20 AM UTC, comment #8: 

I applied Dan's patch for bug #34523.  I think you can move ahead with your patch for consistency.

FYI, linestyle seems to be broken for gnuplot 4.6.6 and 2-D plots now.  For example, "plot (1:10, 'o--')" does not produce a line with breaks--it is solid.

Rik <rik5>
Group administrator
Mon 29 Feb 2016 02:32:44 AM UTC, comment #7: 

opps, the gnuplot syntax wasn't quite equivalent to Octave's linestyles. The ones below are better suited.


set linetype 1 dashtype solid
set linetype 2 dashtype '_'
set linetype 3 dashtype '-.'
set linetype 4 dashtype '.'
plot for [i=1:4] sin(i*x/4)


Ben Abbott <bpabbott>
Group Member
Mon 29 Feb 2016 02:27:34 AM UTC, comment #6: 

I've updated Dan's patch and attached it to bug #34523.

I also stumbled across syntax options for gnuplot's "dashtype" that I was not aware of.

With the exception of ":", Octave's linestyles can be easily rendered using gnuplot by specifying the dashtype to be the linestyle


set linetype 1 dashtype '-'
set linetype 2 dashtype '--'
set linetype 3 dashtype '-.'
set linetype 4 dashtype '.'
plot for [i=1:4] sin(i*x/4)


Once Dan's patch is committed, it should be rather easy to create a patch that produces consistent linestyles across gnuplot's terminals.

Ben Abbott <bpabbott>
Group Member
Mon 29 Feb 2016 12:36:32 AM UTC, comment #5: 

It appears that Dan has already coded a patch that does most of this at bug #34523.  Unfortunately the patch no longer applies cleanly against the current dev branch.

Rik <rik5>
Group administrator
Fri 26 Feb 2016 10:02:22 PM UTC, comment #4: 

Yes. I noticed that gnuplot 5 now supports consistent dashtypes across terminals. I haven't had the time to estimate how much of the code needs to be changed, but am optimistic about the idea.

BTW, the fix for Aquaterm has been applied to the official Gnuplot code. Thus aqua, qt, wxt, and x11 can each produce results that are consistent with postscript.

Ben Abbott <bpabbott>
Group Member
Fri 26 Feb 2016 09:52:41 PM UTC, comment #3: 

@Ben: Is this a placeholder bug report?

It seems that gnuplot 5 supports a "dashtype" option, but no one has coded _gnuplot_has_feature_ to be able to check for its existence.  Nor has _gnuplot_draw_axes_ been modified to make use of it.

Rik <rik5>
Group administrator
Wed 13 Jan 2016 08:19:50 PM UTC, comment #2: 

Presently, the gnuplot linestyles are used and matched up to Octave/Matlab lifestyles. Below is a code snippet from _gnuplot_draw_axes_


1815   if (isfield (obj, "linestyle"))
1816     switch (obj.linestyle)
1817       case "-"
1818         lt = "1";
1819       case "--"
1820         lt = "2";
1821       case ":"
1822         lt = "3";
1823       case "-."
1824         lt = "6";
1825       case "none"
1826         lt = "";
1827       otherwise
1828         lt = "";
1829     endswitch


The "lt" variable refers to gnuplot's line style index number


     set style line <index> default
     set style line <index> {{linetype  | lt} <line_type> | <colorspec>}
                            {{linecolor | lc} <colorspec>}
                            {{linewidth | lw} <line_width>}
                            {{pointtype | pt} <point_type>}
                            {{pointsize | ps} <point_size>}
                            {palette}
     unset style line
     show style line


You'll notice that gnuplot's line style does not allow the dash/dot sequence to be modified. In addition, each of gnuplot's terminals can have different dash/dot sequences for their line styles (i.e. no required consistency).

With the new "dash type", it is now possible to ensure the line styles are consistent across all terminals. I've attached four test pngs using the terminals aqua, qt, wxt, and x11. These were produced using gnuplot 5.0.2 with a patch to permit user defined dash types when using AquaTerm.


Ben Abbott <bpabbott>
Group Member
Wed 13 Jan 2016 05:18:39 PM UTC, comment #1: 

What is the proposed change for Octave?  Currently linestyles do seem to work already.  I used the test code below with gnuplot 4.6.7.


graphics_toolkit gnuplot
plot (1:10, ":");



Rik <rik5>
Group administrator
Wed 13 Jan 2016 12:38:00 AM UTC, original submission:  

With gnuplot v5, it is now possible to specify a "dashtype"

http://www.bersch.net/gnuplot-doc/linetypes,-colors,-and-styles.html#dashtype

This syntax is intended to function across all terminals, and can be used to provide Matlab compatible linestyle for Octave.


# equivalent to ML '-'
set dashtype 5 solid
# equivalent to ML ':'
set dashtype 6 (2,8)
# equivalent to ML '-.'
set dashtype 7 (16,8,2,8)
# equivalent to ML '--'
set dashtype 8 (16,16)



Ben Abbott <bpabbott>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #36580:  changeset.patch added by bpabbott (1KiB - application/octet-stream)
file #36017:  aqua.png added by bpabbott (96KiB - image/png)
file #36018:  wxt.png added by bpabbott (98KiB - image/png)
file #36019:  qt.png added by bpabbott (120KiB - image/png)
file #36020:  x11.png added by bpabbott (38KiB - image/png)

 

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 bpabbott (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 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-03-10 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2016-03-09 rik5 Summarylinetype not respected across Gnuplot terminals linetype not respected across gnuplot terminals
    2016-03-09 bpabbott Attached File- Added changeset.patch, #36580
    2016-02-28 rik5 StatusNeed Info Confirmed
    2016-01-13 bpabbott Attached File- Added aqua.png, #36017
        Attached File- Added wxt.png, #36018
        Attached File- Added qt.png, #36019
        Attached File- Added x11.png, #36020
    2016-01-13 rik5 StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code