Dear gretl users,
I know that this is actually a gnuplot-issue but I thought that some of
may also be interested in it and I somebody else could help me with this.
I would like to generate a clustered histogram in the same vein as the
2nd one here:
http://gnuplot.sourceforge.net/demo_svg_5.0/histograms.html
using gnuplot version 5.
However, my example function below doesn't produce the graph I need, as
only the first column (first bar) is plotted but not the 2nd one. I
already spent a while on this but couldn't find the error.
<hansl>
clear
set echo off
set messages off
set seed 1234
function void plotty (matrix mat, string fname)
string path = "barclust.gp"
sprintf tmpfile "@dotdir/@path"
outfile @tmpfile --write
printf "set encoding utf8 \n"
printf "set auto x \n"
printf "set style data histogram \n"
printf "set style histogram cluster gap 1 \n"
printf "set style fill solid border -1 \n"
printf "set boxwidth 0.9 \n"
printf "plot '-' using 2:xtic(1), '' using 3\n"
loop i=1..rows(mat) -q
loop j=1..cols(mat) -q
if mat[i,j]<0 || mat[i,j]>=0
printf "%.6f", mat[i,j]
else
printf "NaN"
endif
if j<cols(mat)
printf " "
endif
endloop
printf "\n"
endloop
printf "e \n"
outfile --close
gnuplot --input="@tmpfile" --output="@fname"
end function
matrix mat = seq(1,5)'~mnormal(5,2)
string fname = "(a)dotdir/check.pdf"
plotty(mat, fname)
</hansl>
Best,
Artur