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 20:39:18 -0500

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.

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.

Apparently more work will be needed to support the linestyles for x11.

Ben



reply via email to

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