Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GNUplot - How to have an image as a key?

Tags:

gnuplot

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.

enter image description here

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'
like image 672
Murali Avatar asked Nov 08 '22 11:11

Murali


1 Answers

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

like image 91
Joce NoToPutinsWarInUkraine Avatar answered Nov 15 '22 10:11

Joce NoToPutinsWarInUkraine