I have read this article (Gnuplot - plot image at point) showing how to use an image instead of a Point Type on a chart by utilizing a vector containing the names of the images together with in array of values and iteration with the For command.
Is there a "simpler" way to get this effect or is the method shown in the article above the only way to accomplish this goal with gnuplot?
One of my many failed attempts trying to bend gnuplot to my will to use an image instead of a point type:
$DATA<<EOD
1,"c:\temp\image1.png",0.00,0.00
2,"c:\temp\image1.png",424.75,549.75
3,"c:\temp\image1.png",849.50,1099.50
4,"c:\temp\image2.png",1274.25,1649.25
5,"c:\temp\image2.png",1698.00,2198.00
EOD
set terminal windows enhanced size 1700,2200
set datafile separator comma
set style data point
unset xtics
unset ytics
set border 0
set key off
set xrange [0:1699]
set yrange [0:2199]
plot $DATA with image '$2' binary filetype=png center=($3,$4) rgbimage
Thank you Roberto
Current gnuplot (version 5.4) also supports pixmap
objects. These are not exactly point types, but they can be positioned using graph coordinates so that they act as points within a graph. This works for both 2D and 3D graphs.
Here is an example based on the one you show. Note that the plot is created with points
, but the pre-defined pixmaps cover those points.
PIC = "icon64x64.png"
$DATA<<EOD
1 0.00 0.00
2 424.75 549.75
3 849.50 1099.50
4 1274.25 1649.25
5 1698.00 2198.00
EOD
set for [i=1:5] pixmap i PIC center at word($DATA[i], 2), word($DATA[i], 3)
set xrange [0:2000]
set yrange [0:2400]
plot $DATA using 2:3 with points notitle
Other possible uses of pixmap
are shown in the online pixmap demo (best to run this one locally so you can see that the pixmap icon moves with graph in 3D as you rotate interactively.
Edit:
The word
function as shown works only for strings where the individual fields are separated by whitespace. If for some reason it is essential to deal with commas or other field separators, you can look forward to a more general solution in gnuplot 6 (available as a release candidate; full release expected by the end of 2023).
In gnuplot 6 you could use the split
function instead of word
. The revised code to handle comma-separated fields would look like this:
# gnuplot version 6
do for [j=1:5] {
A = split( $DATA[j], "," )
set pixmap j PIC center at A[2], A[3]
}