bugGNU Octave - Bugs: bug #48982, line drawing not compatible with...

 
 

bug #48982: line drawing not compatible with gnuplot version 4.4.0

Submitter:  Dan Sebald <sebald>
Submitted:  Fri 02 Sep 2016 09:37:58 PM UTC
   
 
Category:  Plotting with gnuplot Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  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

Sat 03 Sep 2016 11:17:33 PM UTC, comment #7: 

Looks good to me with gnuplot 4.4, 4.6, and 5.0, both on-screen and printed to png.

Mike Miller <mtmiller>
Group Member
Sat 03 Sep 2016 03:02:04 AM UTC, comment #6: 

@Dan: I pushed your patch.  I also added Mike to the CC list so that he can test with 4.4.

Rik <rik5>
Group administrator
Sat 03 Sep 2016 12:32:49 AM UTC, comment #5: 

Yeah, the {} empty cell notation, analogous to [] from way back...

I think I see what the issue is, and it is a bit confusing because of the gnuplot syntax.

First, let me point out where the problem lies.  This change that causes lines to appear properly, but not of the dash illustrates:


diff --git a/scripts/plot/util/private/__gnuplot_draw_axes__.m b/scripts/plot/ut
--- a/scripts/plot/util/private/__gnuplot_draw_axes__.m
+++ b/scripts/plot/util/private/__gnuplot_draw_axes__.m
@@ -1978,7 +1978,7 @@ function [style, ltidx] = do_linestyle_c

   sidx = 1;
   if (isempty (errbars))
-    if (isempty (lt))
+    if (isempty (lt) && __gnuplot_has_feature__ ("linetype"))
       style{sidx} = "";
     else
       style{sidx} = "lines";


I think that gnuplot_linetype() should probably return something even if there is no dashtype feature or there is no linetype feature (but hold on, "linetype" is the confusion).

I look at gnuplot_linetype() and I see


    elseif (__gnuplot_has_feature__ ("linetype"))
      opt = "linetype";
      switch (obj.linestyle)
        case "-"
          lt = "1";
        case "--"
          lt = "2";
        case ":"
          lt = "3";
        case "-."
          lt = "6";
        case "none"
          lt = "";
        otherwise
          lt = "";
      endswitch
    else
      lt = "";
    endif
    if (! isempty (lt))
      lt = sprintf ("%s %s", opt, lt);
    endif


There are two occurrences of "linetype" at the start of the above hunk, but I think they refer to two different gnuplot concepts.  The _gnuplot_has_feature_ I believe refers to "linetype" as an alternative to "linestyle", while the "opt" linetype is a qualifier for a line style.  That is, in gnuplot 4.4.0 there is no valid

set linetype 9 default;

, for example, but there is a valid qualifier "linetype" in the plot command


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


So, we have double meaning for "linetype", but of course the _gnuplot_has_feature_ can't distinguish between what is being referred to.

Either we have to get more granular on "linetype" within _gnuplot_has_feature_, e.g., "linetype" and "stylelinetype", or we can just assume that the "linetype" option has always existed and just do:


diff --git a/scripts/plot/util/private/__gnuplot_draw_axes__.m b/scripts/plot/ut
--- a/scripts/plot/util/private/__gnuplot_draw_axes__.m
+++ b/scripts/plot/util/private/__gnuplot_draw_axes__.m
@@ -2107,7 +2107,7 @@ function [lt] = gnuplot_linetype (obj)
         otherwise
           lt = "";
       endswitch
-    elseif (__gnuplot_has_feature__ ("linetype"))
+    else
       opt = "linetype";
       switch (obj.linestyle)
         case "-"
@@ -2123,8 +2123,6 @@ function [lt] = gnuplot_linetype (obj)
         otherwise
           lt = "";
       endswitch
-    else
-      lt = "";
     endif
     if (! isempty (lt))
       lt = sprintf ("%s %s", opt, lt);


The only other place that gnuplot_linetype() is used is for patch outlines.  We should somehow comment, or actually better would be to change the name of "gnuplot_linetype()" to clear confusion.  In the attached patch I've done just that...think it over I guess.  If you want to add something new to _gnuplot_has_feature_, I'll look how far back "linetype" has been a valid "line style" qualifier.

I verified that the changeset also works for the line style around patches.

(file #38419)

Dan Sebald <sebald>
Fri 02 Sep 2016 11:36:57 PM UTC, comment #4: 

Ignore my derefencing comment.  Sometimes I just don't get Octave syntax.


x = cell (1,4);
x(3) = {}
error: =: nonconformant arguments (op1 is 1x1, op2 is 0x0)
x{3} = {}
x =
{
  [1,1] = [](0x0)
  [1,2] = [](0x0)
  [1,3] = {}(0x0)
  [1,4] = [](0x0)
}



Rik <rik5>
Group administrator
Fri 02 Sep 2016 11:23:36 PM UTC, comment #3: 

Yes, that seems suspect.  What if you put in a keyboard statement in the if (...) block?  Can you catch the function and restore data{data_idx} after the deletion and then use dbcont to see if it works?

Also, shouldn't it be


data(data_idx) = {};


In other words, it should use indexing '()' rather than dereferencing '{}'.

Rik <rik5>
Group administrator
Fri 02 Sep 2016 11:08:16 PM UTC, comment #2: 

Quick note: It looked to me in the code that the data was getting assigned.  Then I saw this case in the middle of "line" processing that takes the data away:

        if isempty (style{1})
          style{1} = "points";
          data{data_idx} = {};
        endif

This is getting called.

Dan Sebald <sebald>
Fri 02 Sep 2016 09:53:58 PM UTC, comment #1: 

Probably have to step through the code with the debugger.  According the the information in _gnuplot_has_feature_, 'linetype' should be used only for 4.6 and above. 

In _gnuplot_draw_axes_ I see lots of constructs like this


if (__gnuplot_has_feature__ ("linetype"))
  scmd = "linetype";
else
  scmd = "linestyle";
endif


I suppose it's possible that somewhere an instance of this was missed and it needs something like that above.

The other possibility is that the gnuplot_linetype routine is wrong.


function [lt] = gnuplot_linetype (obj)

  if (isfield (obj, "linestyle"))
    if (__gnuplot_has_feature__ ("dashtype"))
      opt = "dashtype";
      switch (obj.linestyle)
        case "-"
          lt = "solid";
        case "--"
          lt = "'_ '";
        case ":"
          lt = "'. '";
        case "-."
          lt = "'-. '";
        case "none"
          lt = "";
        otherwise
          lt = "";
      endswitch
    elseif (__gnuplot_has_feature__ ("linetype"))
      opt = "linetype";
      switch (obj.linestyle)
        case "-"
          lt = "1";
        case "--"
          lt = "2";
        case ":"
          lt = "3";
        case "-."
          lt = "6";
        case "none"
          lt = "";
        otherwise
          lt = "";
      endswitch
    else
      lt = "";
    endif
    if (! isempty (lt))
      lt = sprintf ("%s %s", opt, lt);
    endif
  else
    lt = "";
  endif


"dashtype" is available only with 5.0.  "linetype" is available only with 4.6 and above.  For gnuplot 4.4, both of these would be false and linetype (lt) would be set to "".


Rik <rik5>
Group administrator
Fri 02 Sep 2016 09:37:58 PM UTC, original submission:  

On the discussion list was noted that:

graphics_toolkit ('gnuplot');
plot (1:10, '--');
print -dpng 'test.png';

produces only a blank page with gnuplot version 4.4.0.  I have confirmed this.

I used

drawnow ('x11', "/dev/null", "foo-4.6.6.gp"); ## for gnuplot 4.6.6

and

drawnow ('x11', "/dev/null", "foo-4.4.0.gp"); ## for gnuplot 4.4.0

to create gnuplot command files.  The files differ as:

INTENDED FOR GNUPLOT 4.4.0

set style line 9 default;
set style line 9 linecolor rgb "#0000ff" linewidth 0.500000;
[...snip...]
unset colorbox;
plot "-";
Inf Inf
e
unset obj 1;


INTENDED FOR GNUPLOT 4.6.6

set linetype 9 default;
set linetype 9 linecolor rgb "#0000ff" linetype 2 linewidth 0.500000;
[...snip...]
unset colorbox;
plot "-" binary format='%float64' record=10 using ($1):($2) axes x1y1 title "" with lines linetype 9 \
;
[...string of binary data...]
unset obj 1;


Octave gnuplot scripts are choosing to not plot any lines because of the age of gnuplot.  But, if I change the code intended for gnuplot 4.4.0 so the plot command looks like:


unset colorbox;
plot "-" binary format='%float64' record=10 using ($1):($2) axes x1y1 title "" with lines linestyle 9 \
;
[...string of binary data...]
unset obj 1;


(i.e., "linetype 9" replaced by the older "linestyle 9") the code run through gnuplot 4.4.0 is dashed blue lines, as expected.

Dan Sebald <sebald>

 

(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 mtmiller (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by sebald (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-09-03 mtmiller StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2016-09-03 rik5 StatusNone Ready For Test
        Carbon-Copy- Added mtmiller
    2016-09-03 sebald Attached File- Added octave-gnuplot_linestyletype_bug48982-djs2016sep02.patch, #38419

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code