我面临一个关于多图中边界设置的小问题。虽然我遵循了一些可用的示例,但仍然缺少顶线和底线。
这是代码
**
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:($2--.3095296750) w l lc "black" lw 2 notitle, "bands_cs.dat" every :::32::32 u 1:($2--.3095296750) w l lc rgb "blue" lw 3 notitle,"bands_cs.dat" every :::33::33 u 1:($2--.3095296750) w l lc rgb "blue" lw 3 notitle,"bands_cs.dat" every :::34::34 u 1:($2--.3095296750) w l lc rgb "red" lw 3 notitle,"bands_cs.dat" every :::35::35 u 1:($2--.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 轴采用不同的颜色(没有 y2tics),但其他边框采用黑色。您可以简单地通过
set border 5
删除右边框并通过 set arrow
添加绿线。
检查
help border
和 help margins
和 help 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
结果:
这是 theozf 出色的 answer 的变体。虽然它没有直接解决OP的问题,但对于在谷歌搜索gnuplot多图边框/tic颜色之后到达这里的任何人来说可能会有所帮助。创建:
使用以下 gnuplot 脚本:
set multiplot
set title 'This is a multiplot title' noenhanced
my_height_upper = 0.45
my_height_lower = 0.55 # upper 45%, lower 55%
my_height_start = 0.02
set margins 0,0,1,-1 # l,r,b,t
set key tc variable # colored keys (optional)
# Plot the upper plot, a sqrt(x):
set bmargin 0
set origin 0.10, my_height_lower + my_height_start
set size 0.80, my_height_upper
set ylabel 'Square root abs' off 1.5, 0
set xrange [-1:7]
set xtics format ''
set grid x,y
plot sqrt(abs(x)) lc 'blue'
# Setup for the two lower plots (actually three):
set bmargin
set tmargin 0
set xrange [GPVAL_X_MIN:GPVAL_X_MAX] # keep xrange of upper
set origin 0.10, my_height_start
set size 0.80, my_height_lower
unset title
unset grid
set xlabel ' '
set xtics format ' '
# Plot sin(x):
set border 2 lc "red"
set ylabel 'Sine' tc 'red' off 1.5, 0
set ytics nomirror
set ytics add ('' 1) # avoid overlapping numbers
set key left
plot sin(x) lc 'red'
# Plot int(x):
set border 8 lc "green"
set y2label 'Integer' tc 'green' off -1.2, 0
unset ytics
unset ylabel
set y2tics auto
set key right
plot int(x) axis x1y2 lc 'green'
# Finally add a black border, bottom ticks, and an xlabel:
unset y2tics
unset y2label
set border 15 lc "black"
set xtics format "%h"
set grid x
set xlabel 'This is the xlabel'
set yrange [42:43] # dummy to suppress error msg
plot NaN notitle
unset multiplot