Gnuplot image on axis

后端 未结 1 1866
我寻月下人不归
我寻月下人不归 2021-01-14 10:17

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 ma

相关标签:
1条回答
  • 2021-01-14 10:38

    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

    enter image description here

    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:

    enter image description here

    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:

    enter image description here

    0 讨论(0)
提交回复
热议问题