如何使用 Gnuplot 设置不同颜色的边框设置?

How to set border setting in different colors using Gnuplot?

我遇到了一个关于多图中边界设置的小问题。虽然我正在关注一些可用的示例,但仍然缺少顶线和底线。

这是代码

**

set multiplot
set border lw 2
set origin 0.05,0.49
set size 0.38,0.45
set yrange [-1.5:1.0]
set xrange [0:2.17106]
set ylabel "E-E_F (eV)" offset 0.5 font "Times-Bold, 35"
set ytics 0.5 font "Times-Bold, 35"
unset xlabel
#set title "Cubic" font "Times-Bold,35"
set label "a)" offset -1,12 font "Times-Bold,40"
plot "bands_cs.dat" using 1:(--.3095296750)  w l lc "black" lw 2 notitle, "bands_cs.dat" every :::32::32 u 1:(--.3095296750) w l lc rgb "blue" lw 3 notitle,"bands_cs.dat"   every :::33::33 u 1:(--.3095296750) w l lc rgb "blue" lw 3 notitle,"bands_cs.dat" every :::34::34 u 1:(--.3095296750) w l lc rgb "red" lw 3 notitle,"bands_cs.dat" every :::35::35 u 1:(--.3095296750) w l lc rgb "red" lw 3 notitle

set origin 0.38,0.49
set size 0.14,0.483
unset arrow
unset xtics
unset label
unset yrange
unset xlabel
unset ylabel
#set xrange[0:2000]
set xtics 1000
set yrange[-1.5:1.0]
set border 1+2+4 lt rgb "black"
set title "{/Symbol s}^{AHE}(10^3 Scm^{-1}) "  font "Times-Bold,25"
set key opaque box right samplen 0.8 height 1.2

xmn=-50
xmx=2500
set ytics format "" nomirror
set xtics (" " 1000,\
        " " 2000 ) font "Times-Bold, 35"
set arrow from  xmn, 0.0 to  xmx, 0.0 nohead dt "-"
ymn=0.98
ymx=0
set arrow from 2100,-0.2 to 2100,0 nohead dt "-"
unset xlabel
#set xlabel 0,1,2
set xrange [xmn:xmx]
set y2range [0.95:1.02]
set border 8 lt rgb "dark-green" lw 2
set y2tics 0.1 nomirror textcol rgb "dark-green" font "Times-Bold, 30"
plot "cs_yx.dat" u 2:1 w l notitle ' lc rgb'black' lw 4,"strain_yx.dat" u 3:1 w lp axes x1y2 lc rgb "dark-green" lw 4 pt 7 ps 2  notitle 

** 简而言之,我需要更改绘图的一侧颜色。

假设您只想让第二个图的右侧 y-axis 具有不同的颜色(没有 y2tics),但其他的边框为黑色。您可以简单地通过 set border 5 删除右边框并通过 set arrow 添加一条绿线。

检查 help borderhelp marginshelp arrows

脚本:

### set border in different colors
reset session

set multiplot

    set margins 0,0,-1,-1   # l, r, b, t
    set origin 0.10,0.10
    set size   0.60,0.90
    set border lw 2
    set grid x,y
    plot sin(x)

    set origin 0.70,0.10
    set size   0.20,0.90
    unset ytics
    set border 5             # only top and bottom
    set arrow 1 from graph 1,0 to graph 1,1 lw 2 lc "green" nohead front   # "manual" border
    set xrange [0:10]
    set xtics add ('' 0)     # remove 0 label to avoid overlap with 10 of the 1st plot
    plot cos(x) lc "green"

unset multiplot
### end of script

结果:

补充: 如果你想在右边的彩色轴上有 ytics(实际上,y2tics),你可能必须在多图环境中添加第三个虚拟图。检查以下示例:

脚本:

### set border in different colors including tics
reset session

set multiplot

    set margins 0,0,-1,-1   # l, r, b, t
    set origin 0.10,0.10
    set size   0.60,0.90
    set border lw 2
    set grid x,y
    plot sin(x)

    set origin 0.70,0.10
    set size   0.20,0.90
    unset ytics
    set border 5             # only top and bottom
    set xrange [0:10]
    set xtics add ('' 0)     # remove 0 label to avoid overlap with 10 of the 1st plot
    plot cos(x) lc "green"
    
    set border 8 lw 2 lc "green"
    set format x ''
    set xtics scale 0
    set yrange [GPVAL_Y_MIN:GPVAL_Y_MAX]    # yrange from previous plot
    set y2tics 0.2 nomirror
    set link y2 via y inverse y
    set format y2 ' '
    plot NaN notitle   # dummy plot, plots nothing

unset multiplot
### end of script

结果: