octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnuplot and dashed lines


From: Ben Abbott
Subject: Re: gnuplot and dashed lines
Date: Thu, 20 Dec 2012 21:51:31 -0500

On Dec 20, 2012, at 9:19 PM, Daniel J Sebald wrote:

> On 12/20/2012 07:39 PM, Ben Abbott wrote:
>> 
>> On Dec 20, 2012, at 10:55 AM, Ben Abbott wrote:
>> 
>>> On Dec 20, 2012, at 10:46 AM, CdeMills wrote:
>>> 
>>>> Hello,
>>>> 
>>>> I was struggling to obtain dashed lines without success. At first I believe
>>>> it was MacOs specific; now I've found the problem.
>>>> 
>>>> If you take the content of
>>>> http://gnuplot.sourceforge.net/demo/dashcolor.html
>>>> and paste it into gnuplot interface, you get the same figure as given on 
>>>> the
>>>> web page. If you download the script provided at
>>>> http://gnuplot.sourceforge.net/demo/dashcolor.1.gnu which is supposed to
>>>> give exactly the same result, you don't.
>>>> 
>>>> There is a subtle difference: the script does not include the 'set
>>>> termoption dashed' command at the beginning. This makes a lot of
>>>> differences: by default, it seems that gnuplot renders all lines as solid.
>>>> 
>>>> To verify, it tried this simple script:
>>>> x = 1:10;
>>>> h=plot (x,x,'-;line 1;',x,x+1,'--;line 2;')
>>>> 
>>>> I got a figure with two continuous lines. Then I did
>>>> drawnow("aqua", "/dev/null", false, "debug.gp")
>>>> edited the debug.gp file, added a "set term option dashed" at the 
>>>> beginning,
>>>> then, in a terminal:
>>>> gnuplot<  debug.gp
>>>> 
>>>> and got the dashed lines ! The missing point is thus to add this
>>>> "termoption" at the beginning of the gnuplot script. Another option is to
>>>> create a "~/.gnuplot" with this line:
>>>> set termoption dashed
>>>> 
>>>> Restarted Octave, ran the same script, and got a dashed line directly!
>>>> Dash-dot working too.
>>>> 
>>>> This should be either corrected into the gnuplot interface, either
>>>> documented. Moreover, gnuplot seems to not have a way to query the
>>>> termoption settings. I don't see how to interactively test wether or not
>>>> this feature is supported.
>>>> 
>>>> Regards
>>>> 
>>>> Pascal
>>> 
>>> If you are intetested in making a changeset, the place for this change is 
>>> in __gnuplot_drawnow__.m, or in __go_draw_figure__.m
>>> 
>>> Ben
>> 
>> I'm not sure if the "dashed" option can be used in all terminals, but I 
>> tried the change below.
> 
> Generally no, but now days the most used of the terminals should supported 
> dashed lines.  In gnuplot that dashed-line-support quirk is a bit of a 
> throwback.
> 
> It's odd though that this should just surface now without others noticing a 
> fairly common feature missing from plotting in Octave.  I'm going to check 
> with the gnuplot list on this.
> 
> 
>> diff --git a/scripts/plot/__gnuplot_drawnow__.m 
>> b/scripts/plot/__gnuplot_drawnow__.m
>> --- a/scripts/plot/__gnuplot_drawnow__.m
>> +++ b/scripts/plot/__gnuplot_drawnow__.m
>> @@ -321,6 +321,14 @@
>>          endif
>>        endif
>>      endif
>> +    dashed_terms = {"aqua", "cairolatex", "canvas", "cgm", "context", ...
>> +                    "eepic", "emf", "epslatex", "fig", "pcl5", "tikz", ...
>> +                    "mp", "next", "openstep", "pdf", "pdfcairo", ...
>> +                    "pngcairo", "postscript", "pslatex", "pstex", ...
>> +                    "svg", "tgif", "windows", "wxt", "x11"};
>> +    if (any (strncmp (term, dashed_terms, numel (term))))
>> +      fprintf (plot_stream, "set termoption dashed\n")
>> +    endif
>>    else
>>      ## gnuplot will pick up the GNUTERM environment variable itself
>>      ## so no need to set the terminal type if not also setting the
>> 
>> "aqua" produced a dashed line, but neither qt (no "dashed" option) or x11 
>> did.
> 
> I've tried a rather recent version of gnuplot here.  Qt terminal seems to 
> support dashed lines (introduced on 2011-12-14), but not X11.  Try:
> 
> gnuplot> set term qt
> Terminal type set to 'qt'
> Options are '0'
> gnuplot> test
> [no dashed lines in the right column]
> gnuplot> set termoptions dashed
> gnuplot> test
> [dashed lines in right column]
> gnuplot> set term x11
> Terminal type set to 'x11'
> Options are ' nopersist'
> gnuplot> test
> [no dashed lines]
> gnuplot> set term x11 dashed
> Terminal type set to 'x11'
> Options are ' nopersist dashed'
> gnuplot> test
> [no dashed lines...doesn't seem right]
> gnuplot> set termoptions dashed
> gnuplot> test
> [no dashed lines...expected give previous result]
> 
> The dashed terminal test might not be necessary.  I think (but not sure) that 
> the "set termoption <opt>" is supposed to be a universal type of setting and 
> terminals are supposed to check that.
> 
>> Apparently more work will be needed to support the linestyles for x11.
> 
> I will look into this.  I just tried the latest gnuplot and the "test" plot 
> is a mess in X11.
> 
> Dan

My gnuplot is

        gnuplot 4.6 patchlevel 1

Looking at sourceforge, I think this is the most recent version?  The manual 
for 4.6 has the syntax below for 'set term qt ..."

set term qt {<n>}

                   {size <width>,<height>}
                   {{no}enhanced}
                   {font <font>}
                   {title "title"}
                   {{no}persist}
                   {{no}raise}
                   {{no}ctrl}
                   {close}
                   {widget <id>}

Even though there is no "dashed" mentioned, I do see dashed lines in the "test" 
plot.  hmmm ... perhaps I the check that a term supports "dashed" should be 
skipped?

diff --git a/scripts/plot/__gnuplot_drawnow__.m 
b/scripts/plot/__gnuplot_drawnow__.m
--- a/scripts/plot/__gnuplot_drawnow__.m
+++ b/scripts/plot/__gnuplot_drawnow__.m
@@ -321,6 +321,7 @@
         endif
       endif
     endif
+    fprintf (plot_stream, "set termoption dashed\n")
   else
     ## gnuplot will pick up the GNUTERM environment variable itself
     ## so no need to set the terminal type if not also setting the

Unfortunately, when I use this change, I still don't get dashed lines from 
Octave when using the "qt" terminal.

Also, I looked at the "test" plots for x11. I don't see any dashed lines there.

Ben



reply via email to

[Prev in Thread] Current Thread [Next in Thread]