问题
I know this was asked before a while ago using images for points but I was wondering whether someone can provide more detailed help, or whether any recent changes in gnuplot make this easier?
My question is slightly different and I didn't want to reopen a 6yo question
I'm trying to produce a plot for a weather forecast similar to this: AIX weather widget screenshot
I have some data from openweathermap's api, and an icon set - plotting the temp, rainfall, etc is trivial.. What I would like to do is plot an image/ icon to show the weather just above the temperature plot
It looks like center would work, but how can I get center to correspond to a datapoint - or more accurately to a few pixels above the datapoint
Any alternative suggestions would also be gratefully received
回答1:
Here's how to do it in two steps:
IMG_LIST="cloud.png sun.png"
X=""
Y=""
IMG=""
storedata(x,y,index_img)= \
(X=X.sprintf(" %f",x), \
Y=Y.sprintf(" %f",y), \
IMG=IMG." ".word(IMG_LIST,int(index_img)),y)
plot '-' using 1:(storedata($1,$2,$3))
0.5 23 2
1.5 27 2
2.5 19 1
e
plot [0:3][0:40] for [i=1:words(IMG)] word(IMG,i) binary filetype=png center=(word(X,i),word(Y,i)) dx=0.005 dy=0.05 with rgbimage notitle
First step is to build lists (space separated elements in strings X, Y, and IMG) with the plot data. Then a for-loop plots the images at the desired location. The dx and dy need to be adjusted depending on your image size and the plot ranges (could be automated with GPVAL_* data).
来源:https://stackoverflow.com/questions/36886170/gnuplot-plot-image-at-point