在坐标轴上绘制Gnuplot图片

3
我正在尝试对某个环境中的某些进度进行建模。x轴将表示环境中的位置(基于x坐标)。
为了清晰起见,我想在我的图表的x轴上(环境相当宽且不那么高,因此应该看起来很好)使用一个基于.png的环境图像,基本上作为xtics / x轴标签。
你有什么关于如何处理这个问题的建议吗?
提前致谢!

你想要包含这个PNG文件,还是从中提取一些数据?无论哪种情况,你都可以使用例如 plot 'file.png' binary filetype=png 并且可能使用 dxdyorigin 来调整比例:例如 plot 'file.png' binary filetype=png dx=0.1 dy=0.01 origin=(10,10) - Christoph
我不需要从中检索任何数据。我尝试了你描述的方法,我可以在里面得到图片,但是有一些问题。首先,由于我添加的颜色框,颜色会出现问题。我尝试了许多变体,但都没有成功。此外,它只允许我将图片放在图中,而不是实际的轴上。虽然这样有点不太美观,但还是可以的。 - DribbelDog
忘了提到,你必须使用 with rgbimage。我马上会发布一个答案。 - Christoph
1个回答

3
您可以使用一个plot命令同时绘制图像和数据,或者使用multiplot。第一种方式更简单,但是图像在绘图内部;第二种方式稍微复杂一些,但允许任意位置放置“轴图像”。

用于轴的虚拟图像“gradient.png”如下:

enter image description here

一个plot命令:

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

结果如下:

结果是:

enter image description here

使用多图

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

如您所见,这需要更多的努力。具体解释如下:

  • 您必须设置明确的边距,以便坐标轴图像可以准确地放置在主绘图下方。

  • 在绘制坐标轴图像之前,您必须删除ticslabels,将范围重置为autoscale等(因此您还必须设置固定的lmarginrmargin)。

  • 要绘制图像本身,请使用绘图样式with rgbimage

  • 您必须微调xticsxlabel偏移量以及边距。

最终生成的图片如下:

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接