Gnuplot image on axis

半世苍凉 提交于 2019-12-19 09:55:12

问题


I'm trying to model a certain progress through some environment. The x axis would represent the location (based on x coordinate) in the environment.

In order to make this clear, I'd like an image of the environment (based on a .png) on the x axis (the environment is rather wide and not that high, so it should look good) of my plot, basically as an xtics/x-axis label.

Do you have any suggestions on how to approach this?

Thanks in advance!


回答1:


You can either plot both the image and the data in one plot command, or with multiplot. The first variant is easier, but the image is inside the plot, the other is a bit more complicated, but allows arbitrary positioning of the "axis image".

The dummy image "gradient.png" for the axis is

One plot command:

set yrange[0:1]
set xrange[0:1]
plot 'gradient.png' binary filetype=png dx=0.0015 dy=0.002 with rgbimage t '',\
     x**2

The result is:

Using multiplot

set yrange[0:1]
set xrange[0:1]

set lmargin at screen 0.1
set rmargin at screen 0.98
set tmargin at screen 0.98
set bmargin at screen 0.2
set xtics offset 0,-1.5
set xlabel 'xlabel' offset 0,-1.5
set ylabel 'ylabel'

set multiplot
plot x**2

set tmargin at screen 0.2
set bmargin at screen 0.15
unset border
unset tics
unset xlabel
unset ylabel
unset key
set autoscale xy
plot 'gradient.png' binary filetype=png with rgbimage 
unset multiplot

As you can see, this requires a bit more effort. To explain the details:

  • You must set explicit margins so that the axis image can be placed exactly below the main plot.

  • Before plotting the axis image, you must remove tics, labels, reset ranges to autoscale etc. (Therefore you must also set fixed lmargin and rmargin).

  • To plot the image itself, use the plotting style with rgbimage.

  • You must fine-tune the xtics and xlabel offset, as well as the marings.

The resulting image is:



来源:https://stackoverflow.com/questions/18398152/gnuplot-image-on-axis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!