对 fillcurved 的绘图标题重新排序

对 fillcurved 的绘图标题重新排序

我有一个漂亮的 gnuplot 图形,我想在其中更改键中的标签。我遇到的问题与 fillcurves 选项有关。为了让事情变得更容易,我附上了图片。正如您所看到的,关键标签是 2 - 1 - 3,而我希望有 1 - 2 - 3,同时保持相同的填充曲线模式。当然,简单地改变我的情节的顺序,会给我 1 - 2 - 3,但填充的模式也会相应地改变,我想避免这种情况。我试图通过使用NaNgnuplot 中的可能性以某种方式破解它(https://stackoverflow.com/questions/10614654/gnuplot-legend-order)但这里的问题是填充物不同。在检查 gnuplot 文档时(http://www.bersch.net/gnuplot-doc/filledcurves.html)我意识到没有办法修复该模式,但我想应该有某种方法。为了进行测试,我附加了 gnuplot 脚本。

在此输入图像描述

#!/bin/gnuplot
#------------------------------------------------------------------------------

set grid
set key right top
set xrange [20:220]

set style line 20 lw 2 lc rgb 'black'
set border linestyle 20
set style line 1 lw 2.0 lc rgb 'dark-gray'
set style line 2 lw 2.0 lc rgb '#202020'
set style line 3 lw 2.0 lc rgb 'gray'
set style fill transparent pattern 2


#------------------------------------------------------------------------------
A=-1.74959e-14
B=-1.87199e-12
C=1.87756e-9
DeltaBDP=0.45e-9

OffsetBP=0.05e-9
DeltaBP=0.8e-9

OffsetB=0.7e-9
DeltaB=0.8e-9

# 
f(x)=A*x**2+B*x+C
g(x)=f(x)+DeltaBDP

# Beta P
h(x)=f(x)+OffsetBP
i(x)=h(x)+DeltaBP

# Beta
j(x)=h(x)+OffsetB
k(x)=j(x)+DeltaB

#------------------------------------------------------------------------------

set terminal epslatex
set output 'tex/foobar.tex'
plot \
'+' using 1:(j($1)*1e9):(k($1)*1e9) with filledcurves closed lc rgb 'dark-gray' t '2' , \
'+' using 1:(f($1)*1e9):(g($1)*1e9) with filledcurves closed lc rgb 'dark-gray' t '1', \
'+' using 1:(h($1)*1e9):(i($1)*1e9) with filledcurves closed lc rgb '#202020' t '3', \
f(x)*1e9 w l ls 1 t '', \
g(x)*1e9 w l ls 1 t '', \
h(x)*1e9 w l ls 2 t '', \
i(x)*1e9 w l ls 2 t '', \
j(x)*1e9 w l ls 3 t '', \
k(x)*1e9 w l ls 3 t ''


#------------------------------------------------------------------------------

答案1

我现在无法测试它,但也许此页面上的第二个答案确实有效: https://stackoverflow.com/questions/6290504/reordering-gnuplot

答案2

如果有人遇到同样的问题,解决方案很简单(一如既往)。搜索完关键字后,pattern style fill如何处理就很明显了。首先,正如我已经做的和@ksyrium 也提到的那样,取消设置图中的标题。随后,NaN在使用 选择模式的同时添加绘图fill pattern <int>。这样做,NaN可以根据需要更改图中的顺序。

plot \
'+' using 1:(j($1)*1e9):(k($1)*1e9) with filledcurves closed lc rgb 'dark-gray' t '1real', \
'+' using 1:(f($1)*1e9):(g($1)*1e9) with filledcurves closed lc rgb 'dark-gray' t '2real', \
'+' using 1:(h($1)*1e9):(i($1)*1e9) with filledcurves closed lc rgb '#202020' t '3real', \
f(x)*1e9 w l ls 1 t '', \
g(x)*1e9 w l ls 1 t '', \
h(x)*1e9 w l ls 2 t '', \
i(x)*1e9 w l ls 2 t '', \
j(x)*1e9 w l ls 3 t '', \
k(x)*1e9 w l ls 3 t '', \
NaN with filledcurves closed fill pattern 2 lc rgb 'dark-gray' t '1', \
NaN with filledcurves closed fill pattern 3 lc rgb 'dark-gray' t '2', \
NaN with filledcurves closed fill pattern 4 lc rgb '#202020' t '3'

相关内容