In Gnuplot, the linetype
or lt
flag allows the user to select the line type (dashed, dotted, solid, etc).
I'm using a Python wrapper called Gnuplot-Py. Here's an example:
import Gnuplot
data1 = [[3, 0.03], [4, 0.02], [5, 0.017]]
data2 = [[3, 0.027], [4, 0.015], [5, 0.014]]
gp = Gnuplot.Gnuplot(persist = 1)
gp('set terminal x11 size 350,225')
gp('set pointsize 2')
gp('set yrange [0.0:0.05]')
plot1 = Gnuplot.PlotItems.Data(data1, with_="linespoints lt rgb 'black' lw 6 pt 1", title="data1")
plot2 = Gnuplot.PlotItems.Data(data2, with_="linespoints lt rgb 'blue' lw 6 pt 8", title="data2")
gp.plot(plot2, plot1)
epsFilename='testLines.eps'
gp.hardcopy(epsFilename, terminal = 'postscript', enhanced=1, color=1) #must come after plot() function
gp.reset()
Here's the output:
As you can see in the above code, lt
(linetype) is in the Gnuplot.PlotItems.Data(..., with_=...)
commands. In plain Gnuplot, we would just do lt 1
to choose line type 1. However, Gnuplot-Py seems to arbitrarily choose the line type (notice that one line is solid, and one line is dashed in the above plot). Let's try a couple of strategies for manually changing the line type in Gnuplot-Py...
Strategy 1. I tried lt 1
instead of lt
in the with_
string. This throws an error, but it still produces the same plot as we saw above.
plot1 = Gnuplot.PlotItems.Data(data1, with_="linespoints lt 1 rgb 'black' lw 6 pt 1", title="data1") #returns the error `line 0: ';' expected
Strategy 2. I also tried removing lt
from the with_
string. This throws an error and ignores the formatting for the data1
line (see green line for data1
below).
plot1 = Gnuplot.PlotItems.Data(data1, with_="linespoints rgb 'black' lw 6 pt 1", title="data1") #returns the error `line 0: ';' expected
Strategy 3. If I add gp('set style lt 1')
, I again get the error line 0: expecting 'data', 'function', 'line', 'fill' or 'arrow'
, and the plot is unchanged from the original shown above.
gp('set style line 1 lc rgb "blue"')
etc. – mgilson