I'm trying to plot two data series in the same graph with multiplot. I would like each of the two data series to be plotted with a different palette. So far I've been trying with multiplot,
set multiplot layout 1,1
#
set palette rgb 21,22,23
splot "S1" using ($1):($2):($3):($5) with points pt 7 ps 3 palette notitle, \
"S1" using ($1):($2):($3):($5) with impulses linecolor "black" notitle
#
set palette rgb 23,28,3
splot "S1" using ($1):($2):($3):($5) with points pt 7 ps 3 palette notitle, \
"S2" using ($1):($2):($3):($5) with impulses linecolor "black" notitle
#
unset multiplot
however, I can not visualize in the X11 terminal the two series at the same time.
Any idea?
Related
I am using Windows 10 and Gnuplot 5.0.
I have a script to plot several graphs simultaneously:
GNUTERM = "wxt"
set terminal wxt
set termoption enhanced
set encoding iso_8859_1
set multiplot layout 1,3
set xtics out
set ytics out
set xtics nomirror
set ytics nomirror
set xzeroaxis linetype 2 linewidth 1.5
show xzeroaxis
# Graph1
set key center right
set xrange [3.3:9.0]
set yrange [-0.1:1.10]
set title "Title 1"
set xlabel "x"
set ylabel "y"
plot \
"results_1.dat" u 1:2:4 title "exp." with e pointtype 9 pointsize 0.5 linecolor rgb "red" , \
"results_1.dat" u 1:3 title "fit." with line linecolor rgb "black" linewidth 2 dashtype 2 smooth bezier
# Graph2
set xrange [3.3:9.0]
set yrange [-0.1:1.10]
set key top right
set title "Title 2"
set xlabel "x"
set ylabel "y"
plot \
"results_2.dat" u 1:2:4 title "exp." with e pointtype 9 pointsize 0.5 linecolor rgb "blue", \
"results_2.dat" u 1:3 title "fit." with line linecolor rgb "black" linewidth 2 dashtype 2 smooth bezier
# Graph3
set xrange [3.3:9.0]
set yrange [-0.1:1.10]
set key outside vertical top right
set title "Title 3"
set xlabel "x"
set ylabel "y
plot \
"results_3.dat" u 1:2:4 title "exp." with e pointtype 9 linecolor rgb "red", \
"results_3.dat" u 1:3 title "fit." with line linecolor rgb "black" linewidth 2 dashtype 2 smooth bezier
unset multiplot
pause 3
reread
However, instead of getting the legend outside only for the graph 3, all legends are shown outside the graphs (see attached image)
I want legends 1 and 2 inside the graphs and legend 3 outside. What's wrong in my script?
Any help is appreciated.
Supernono06
It's hard to say without being able to run your script, but if I had to guess I'd say that you request the legend to be outside for graph 3, and when you reread the script you don't put it back inside. Try something like
set key inside center top
for the first graph (or add a reset statement to the beginning of your script).
I understand that we can omit the key in GNUplot using unset key. If I want to insert a small image to signify the key onto a XY 2-D plot, how to do it? In MS-Excel, it is just a matter of copying an image and pasting it on to the plot and adjusting its placement and size. Can such a thing be done in GNUPlot too? By what plot option? I am attaching a sample a of what I expect in a multiplot I made (the plot on the top left). And I have the small molecule image as a png file. I have also listed the code below. Please help me. Thanks.
reset
set size 1,1
set multiplot
unset key
#CPD
set size 0.5,0.5
set origin 0,0.5
unset title
plot 'Practice1.dat' using 1:2 w points lw 3 lc rgb 'red'
plot 'Practice1.dat' using 1:6 smooth csplines lw 3 lc rgb 'red'
#Ethene
set size 0.5,0.5
set origin 0.5,0.5
set title 'Ethene'
plot 'Practice1.dat' using 1:3 w l lw 3 lc rgb 'blue'
#Benzene
set size 0.5,0.5
set origin 0,0
set title 'Benzene'
plot 'Practice1.dat' using 1:4 smooth csplines lw 3 lc rgb 'green'
#H2
set size 0.5,0.5
set origin 0.5,0
set title 'H2'
plot 'Practice1.dat' using 1:5 w l lw 3 lc rgb 'black'
The image will be a plot in itself.
plot "image.png" binary filetype=png center=(975,40) dx=200 w rgbimage, \
'Practice1.dat' using 1:2 w points lw 3 lc rgb 'red', \
'Practice1.dat' using 1:6 smooth csplines lw 3 lc rgb 'red'
Note that you should avoid having several plot commands without changing origin/size in multiplot, as the labels and borders are overlaid and this may change their appearance depending on terminal (because e.g of antialiasing), hence the usage of , and the splitting of the command on multiple lines (with \)
Note also that set multiplot could have done the layout of your simple 2x2 plot all by itself for you, set multiplot layout 2,2
I've been trying to make 3d plots of surfaces from datasets using gnuplot. I have been partially successful using the following code:
set view 65,45
unset colorbox
set lmargin 14
set pm3d depthorder nohidden3d
set ylabel "angles [deg]"
set zlabel offset -2,0 "energy [eV]"
set palette defined (0 'blue', 1 "blue", 3 "blue", 4 'red')
splot "S1.dat" u 1:2:3:4 w pm3d ti "S1", "T2.dat" u 1:2:3:4 w pm3d ti "T2"
which results in the following image:
image1
The problem is, the border region (the "seam") between the two surfaces is not clearly visible because the tiles are colored with one color only. To make things clearer, here's what I obtain without pm3d (with or without hidden3d):
set terminal png size 800,800
set output "testimg2.png"
set view 65,45
unset colorbox
set lmargin 14
set isosamples 19,44
set hidden3d
set ylabel "angles [deg]"
set zlabel offset -2,0 "energy [eV]"
set palette defined (0 'blue', 1 "blue", 3 "blue", 4 'red')
#splot "S1.dat" u 1:2:3:4 w pm3d ti "S1", "T2.dat" u 1:2:3:4 w pm3d ti "T2"
splot "S1.dat" u 1:2:3 w l lc rgb "blue" ti "S1", "T2.dat" u 1:2:3 w l lc rgb "red" ti "T2"
unset hidden3d
set output "testimg3.png"
splot "S1.dat" u 1:2:3 w l lc rgb "blue" ti "S1", "T2.dat" u 1:2:3 w l lc rgb "red" ti "T2"
image 2 (hidden3d)
image 3 (no hidden3d)
So essentially what I want is a picture like my second image, where you can clearly see the border between the surfaces, but with filled tiles.
The closest I've seen to this is fig 3 in the following page:
http://www.gnuplotting.org/klein-bottle/
where you can see where the bottle meets the handle.
Can anyone help? If this is not possible with gnuplot, can anyone suggest an alternative?
to plot 2 planes in 3d, enter functions for z, comma separated, e.g.
plane 1: 4x+2y+2z = 12
plane 2: -3x-2y+8z = 12
gnuplot> splot (-4*x-2*y+12)/2, (3*x+2*y+12)/8
plot of 2 planes
The script works, without any change in color, however:
plot '_numXY' using 2:3:(sprintf('%d', $1)) \
with labels offset 0,1 point pointtype 6 ps 2 notitle lc rgb "blue"
The points are black. I want to see the points in blue color.
Why does lc rgb "blue" not work?
The lc settings are ignored for the labels plotting style if they don't follow immediately the point option. In your case you must only place the notitle at the end.
plot '_numXY' using 2:3:(sprintf('%d', $1)) \
with labels offset 0,1 point pointtype 6 ps 2 lc rgb "blue" notitle
As a demonstration example:
set samples 11
set xrange [0:10]
plot '+' using 1:1:(sprintf('%d', $1)) \
with labels offset 0,1 point pointtype 6 ps 2 lc rgb "blue" notitle
The result with 4.6.5 is:
I would like to reproduce a bar chart like this one, i.e.: multiple groups, every group has many bars (4 bars in my case), each bar is segmented in a few slices (two slices in my case).
In my case, I have four algorithms applied on vectors of different sizes (2^0 to 2^20). Each algorithm has two "sections", local computation and communication. For each vector size I want to show the time required by each algorithm to perform the local computation and the communication, along with the total time corresponding to the sum of these two sections.
As a result, I would like to have a group for every vector size. In each group there are four bars corresponding to the four algorithms and each bar is segmented in a (e.g.) red part corresponding to the local computation and a blue part corresponding to the communication.
Is this feasible with gnuplot? I can provide data in whatever format is useful.
Many thanks in advance.
For your data set it doesn't make sense to stack the local and comm parts, because the comm part is to small to see it in the graph. In any case it would also be quite tricky to combine stacked and clustered, depending on the further requirements (legend entries, tick labels etc).
Here is an example of how to plot a clustered histogram for your data set:
set style histogram clustered gap 1
set style data histogram
set style fill solid 1.0 noborder
set termoption enhanced
set xtics out nomirror
myxtic(x) = sprintf('2^{%d}', int(floor(log(x)/log(2) + 0.5)))
plot 'test.dat' using ($2+$3):xtic(myxtic(stringcolumn(1))) title 'Algorithm 1',\
for [i=2:4] '' using (column(2*i)+column(2*i+1)) title sprintf('Algorithm %d', i)
The result is:
To group by algorithm, you can create new groups with the newhistogram keyword:
set style histogram rowstacked title offset 4,1
set boxwidth 0.9 relative
set style fill solid 1.0 border lt -1
set xtics rotate by 90 right
plot newhistogram "Algorithm 1" lt 1,\
'test.dat' using 2:xtic(1) title columnheader, \
'' using 3 title columnheader,\
newhistogram "Algorithm 2" lt 1,\
'test.dat' using 4:xtic(1) notitle, \
'' using 5 notitle,\
newhistogram "Algorithm 3" lt 1,\
'test.dat' using 6:xtic(1) notitle, \
'' using 7 notitle,\
newhistogram "Algorithm 4" lt 1,\
'test.dat' using 8:xtic(1) notitle, \
'' using 9 notitle
The local and comm dat are stacked, but the comm part is so small, that you cannot see it in the graph (only when you zoom in).
For the output I used 4.6.3 and the following settings:
set terminal pngcairo size 1000,400
set output 'test.png'
set xtics font ',6'
The result is:
A bit more sophisticated display of the xtics requires some tricking, because for histograms the xtics aren't treated as being numerical, but rather strings. Here is an example:
set terminal pngcairo size 1000,400
set output 'test.png'
set style histogram rowstacked title offset 0,-0.5
set bmargin 3
set boxwidth 0.9 relative
set style fill solid 1.0 border lt -1
set termoption enhanced
set xtics out nomirror
myxtic(x) = (int(floor(log(x)/log(2) + 0.5)) % 5 == 0) ? sprintf('2^{%d}', int(floor(log(x)/log(2) + 0.5))) : ""
plot newhistogram "Algorithm 1" lt 1,\
'test.dat' using 2:xtic(myxtic(real(stringcolumn(1)))) title columnheader, \
'' using 3 title columnheader,\
newhistogram "Algorithm 2" lt 1,\
'test.dat' using 4:xtic(myxtic(real(stringcolumn(1)))) notitle, \
'' using 5 notitle,\
newhistogram "Algorithm 3" lt 1,\
'test.dat' using 6:xtic(myxtic(real(stringcolumn(1)))) notitle, \
'' using 7 notitle,\
newhistogram "Algorithm 4" lt 1,\
'test.dat' using 8:xtic(myxtic(real(stringcolumn(1)))) notitle, \
'' using 9 notitle
With the result