Dear all,
I am experiencing some minor issues when trying to plot things.
Actually, I am not sure whether these are problems related to gnuplot or
to gretl.
First, I really like the new "--font=fontspec" option; thanks again for
implementing this. I wrote a small function for plotting vectors which
allows the user to set a bunch of different options. You can find the
function at the bottom
I ran the following 5 scenarios of which only scenario 1 works as intended.
First there seems to be a problem with the ""literal set mono" option
which rules out controlling the line width under both the "display" and
"pdf" output.
Second, when the output format is pdf, I also can't control the font
size; irrespective of the dashed and monochrome options.
Thanks for help and Happy Easter!
Artur
<hansl>
# Example
clear
set verbose off
open denmark.gdt -q
mat = {LRM}~{LRY}
string fname="display"
string title = ""
string xlab = ""
string ylab = ""
timedim = 1
dashed = 1
single = 0
fonts = 25
leg = 0
psleg = 0
lw = 5
ps = 0.5
pival = 0
ymin = -999
ymax = -999
# 1) Dashed and colored, png: works fine
mono = 0
matlineplot (mat,fname,title,xlab,ylab,timedim, \
dashed,mono,single,fonts,leg,psleg,lw, \
ps,pival,ymin,ymax)
# 2) Dashed and mono, png: line width not correct
mono=1
matlineplot (mat,fname,title,xlab,ylab,timedim, \
dashed,mono,single,fonts,leg,psleg,lw, \
ps,pival,ymin,ymax)
# 3) Solid and colored, pdf: font size not correct
dashed = 0
mono=0
string fname="out3.pdf"
matlineplot (mat,fname,title,xlab,ylab,timedim, \
dashed,mono,single,fonts,leg,psleg,lw, \
ps,pival,ymin,ymax)
# 4) Dashed and colored, pdf: font size not correct
mono=0
string fname="out1.pdf"
matlineplot (mat,fname,title,xlab,ylab,timedim, \
dashed,mono,single,fonts,leg,psleg,lw, \
ps,pival,ymin,ymax)
# 5) Dashed and mono, pdf: font size not correct
mono=1
string fname="out2.pdf"
matlineplot (mat,fname,title,xlab,ylab,timedim, \
dashed,mono,single,fonts,leg,psleg,lw, \
ps,pival,ymin,ymax)
</hansl>
<hansl-fun>
function void matlineplot (matrix mplot,
string fname, string title, string xlab, string ylab,
int timedim "0=NO-->last col =x-axis, 1=YES",
int dashed[0:1:0] "Dashed lines: 0=NO, 1=YES",
int mono[0:1:0] "Monochrome: 0=No, 1=YES",
int singleyaxis[0:1:0] "Single y-axis: 0=no, 1=yes",
int fontsize "Set font size in pt",
int legend [0:1:1] "0=off, 1=on",
int poslegend "Legend position",
scalar lw "linewidth",
scalar ps "point size",
int pival[0::4] "Point interval",
scalar ymin "Min. y-value or -999", scalar ymax "Max. y-value or
-999")
# Inspired by
http://www.gnuplotting.org/attractive-plots/
sprintf PS "%.2f", ps
sprintf LW "%.2f", lw
sprintf PIV "%d", pival
if legend==0
sprintf strLEG "set nokey"
else
if poslegend == 0
string strLEG = "set key outside below"
elif poslegend == 1
string strLEG = "set key top left"
elif poslegend == 2
string strLEG = "set key top right"
elif poslegend == 3
string strLEG = "set key bottom left"
elif poslegend == 4
string strLEG = "set key bottom right"
endif
endif
if timedim==0
string optts = ""
else
string optts = "time-series"
endif
if dashed==0
string optdash = ""
else
string optdash = "literal set for [i=1:5] linetype i dashtype i"
endif
if mono==0
string optmono = ""
else
string optmono = "literal set mono"
endif
if singleyaxis==0
string syax = ""
else
string syax = "single-yaxis"
endif
sprintf optfs "font=\"sans,%d\"", fontsize
if ymin!=-999 && ymax!=-999
sprintf syrange "set yrange[%.5f:%.5f] \n", ymin, ymax
elif ymin!=-999 && ymax==-999
sprintf syrange "set yrange[%.5f:] \n", ymin
elif ymin==-999 && ymax!=-999
sprintf syrange "set yrange[:%.5f] \n", ymax
else
sprintf syrange "set yrange[:] \n"
endif
plot mplot
options with-lp @optts @syax @optfs
#printf "set term pdfcairo lw %.2f", lw
literal @strLEG # Legend options
@optdash
@optmono
literal set title "@title"
literal set xlabel "@xlab" offset 0,1 # Move xlabel closer to
the x-axis
literal set ylabel "@ylab"
literal set y2tics
literal set xtics out offset 0,0.7 # Move xtics cloer to the
x-axis
literal set ytics out
literal @syrange
#2) put the border more to the background by applying it
# only on the left and bottom part and put it and the tics in gray
literal set style line 11 lc rgb "#808080" lt 1
literal set border 3 back ls 11 # get rid of upper + left border
literal set tics nomirror
#add a slight grid to make it easier to follow the exact
position of the curves
literal set style line 12 lc rgb "#808080" lt 0 lw 1 # light
grey color
literal set grid back ls 12
# Line Styles
literal set linetype 1 lc rgb "black" pt 5 ps @PS lw @LW
pointinterval @PIV # --- blue
literal set linetype 2 lc rgb "cyan" pt 7 ps @PS lw @LW
pointinterval @PIV # --- grey
literal set linetype 3 lc rgb "red" pt 3 ps @PS lw @LW
pointinterval @PIV # --- blue
literal set linetype 4 lc rgb "#0000ff" pt 1 ps @PS lw @LW
pointinterval @PIV # --- red
literal set linetype 5 lc rgb "#5e9c36" pt 2 ps @PS lw @LW
pointinterval @PIV # --- green
literal set linetype 6 lc rgb "grey" pt 2 ps @PS lw @LW
pointinterval @PIV # --- green
end plot --output="@fname"
end function
</hansl-fun>