Gnuplot

重新排序填充曲線的繪圖示題

  • April 17, 2019

我有一個漂亮的 gnuplot 圖形,我想在其中更改鍵中的標籤。我遇到的問題與填充曲線選項有關。為了方便起見,我附上了圖片。如您所見,關鍵標籤是 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 ''


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

如果有人遇到同樣的問題,解決方案很簡單(一如既往)。搜尋關鍵字後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'

我現在無法測試它,但也許此頁面上的第二個答案確實有效: https ://stackoverflow.com/questions/6290504/reordering-gnuplot

引用自:https://unix.stackexchange.com/questions/421480