如何增加 filledcurves 绘图样式的关键符号?
How can I increase the key symbol for filledcurves plot style?
我想增加filledcurves
情节风格的关键符号。我可以使用 set key samplen <value>
控制长度,但不能控制它的高度。我可以达到想要的结果,但是使用的方法很麻烦,并且取决于使用的大小图和字体。
我使用了 datafile.dat
文件
1 1270 834
2 1112 900
3 794 982
4 656 710
和这段代码
reset
set encoding utf8
set terminal pngcairo size 500,500 font "Segoe UI,10"
set output "boxes.png"
set key title "{/:Bold Auto key}" Left reverse samplen 2
set tics out nomirror
set xrange [0:5]
unset xtics
set palette defined (\
1 "dark-violet",\
2 "#009e73",\
3 "#56b4e9",\
4 "#e69f00"\
)
unset colorbox
set errorbars small
set macros
style = "solid 0.5 border lt -1"
set style fill @style
# -----------------------------------------------
posX = 0.55 # x position (at screen)
posY = 0.9 # y position (at screen)
shiftY = 0.035 # shift in y direction (from up to down)
sizeX = 0.020 # box width
sizeY = 0.012 # box height
set label "{/:Bold Manual key}" at screen posX, posY left offset 0,1.2
set obj rect center screen posX,posY-0*shiftY size screen 2*sizeX,2*sizeY fc ls 1 fs @style
set obj rect center screen posX,posY-1*shiftY size screen 2*sizeX,2*sizeY fc ls 2 fs @style
set obj rect center screen posX,posY-2*shiftY size screen 2*sizeX,2*sizeY fc ls 3 fs @style
set obj rect center screen posX,posY-3*shiftY size screen 2*sizeX,2*sizeY fc ls 4 fs @style
set arrow from screen posX-sizeX, posY-4*shiftY to screen posX+sizeX, posY-4*shiftY lw 3 nohead
set label "Method 1" at screen posX, posY-0*shiftY left offset 2,0.05
set label "Method 2" at screen posX, posY-1*shiftY left offset 2,0.05
set label "Method 3" at screen posX, posY-2*shiftY left offset 2,0.05
set label "Method 4" at screen posX, posY-3*shiftY left offset 2,0.05
set label "Reference" at screen posX, posY-4*shiftY left offset 2,0.05
# -----------------------------------------------
plot \
keyentry w filledcurves ls 1 title "Method 1",\
keyentry w filledcurves ls 2 title "Method 2",\
keyentry w filledcurves ls 3 title "Method 3",\
keyentry w filledcurves ls 4 title "Method 4",\
"datafile.dat" u 1:2:0 w boxes lc palette notitle,\
"" u 1:3:(0.5) w xerrorbars ls -1 pt -1 lw 3 title "Reference"
做这个剧情
还有其他方法吗?
还有别的办法吗?是的,但是有点难看。键样本的高度由用于键标题的字体大小决定。您可以通过将键设置为使用大字体然后覆盖每个情节标题的实际文本来滥用它。
以下示例将关键字体设置为 20 磅,并在撰写标题文本时使用增强文本模式将大小缩小回 10 磅。您可以忽略复杂的 using
和 every
位,这只是生成一些假数据进行绘图的一种方式。
set term pngcairo size 500,500 font "ArnoPro,10"
set output "boxes.png"
$DATA << EOD
5
2
4
3
1
EOD
set yrange [0:6]
set style fill solid 1.0 border lc "black"
set boxwidth 0.3
set key font "ArnoPro,20" enhanced
plot for [i=1:5] $DATA every ::(i-1)::(i-1) using (i):(column(1)) with boxes \
title sprintf("{/ArnoPro=10 Method %d}", i)
根据@Ethan 的解决方案,您还可以绘制超出范围或使用 NaN
.
的非常粗的虚拟线
plot for [i=1:5] NaN w l lw 13 lt i ti sprintf(" Method %d",i)
代码:
### enlarge height of key sample
reset session
$DATA << EOD
5
2
4
3
1
EOD
set yrange [0:6]
set style fill solid 1.0 border lc "black"
set boxwidth 0.3
set key samplen 2 reverse
plot for [i=1:5] $DATA every ::(i-1)::(i-1) using (i):(column(1)) with boxes \
title sprintf("Method %d", i), \
for [i=1:5] NaN w l lw 13 lt i ti sprintf(" Method %d",i)
### end of code
结果:
我想增加filledcurves
情节风格的关键符号。我可以使用 set key samplen <value>
控制长度,但不能控制它的高度。我可以达到想要的结果,但是使用的方法很麻烦,并且取决于使用的大小图和字体。
我使用了 datafile.dat
文件
1 1270 834
2 1112 900
3 794 982
4 656 710
和这段代码
reset
set encoding utf8
set terminal pngcairo size 500,500 font "Segoe UI,10"
set output "boxes.png"
set key title "{/:Bold Auto key}" Left reverse samplen 2
set tics out nomirror
set xrange [0:5]
unset xtics
set palette defined (\
1 "dark-violet",\
2 "#009e73",\
3 "#56b4e9",\
4 "#e69f00"\
)
unset colorbox
set errorbars small
set macros
style = "solid 0.5 border lt -1"
set style fill @style
# -----------------------------------------------
posX = 0.55 # x position (at screen)
posY = 0.9 # y position (at screen)
shiftY = 0.035 # shift in y direction (from up to down)
sizeX = 0.020 # box width
sizeY = 0.012 # box height
set label "{/:Bold Manual key}" at screen posX, posY left offset 0,1.2
set obj rect center screen posX,posY-0*shiftY size screen 2*sizeX,2*sizeY fc ls 1 fs @style
set obj rect center screen posX,posY-1*shiftY size screen 2*sizeX,2*sizeY fc ls 2 fs @style
set obj rect center screen posX,posY-2*shiftY size screen 2*sizeX,2*sizeY fc ls 3 fs @style
set obj rect center screen posX,posY-3*shiftY size screen 2*sizeX,2*sizeY fc ls 4 fs @style
set arrow from screen posX-sizeX, posY-4*shiftY to screen posX+sizeX, posY-4*shiftY lw 3 nohead
set label "Method 1" at screen posX, posY-0*shiftY left offset 2,0.05
set label "Method 2" at screen posX, posY-1*shiftY left offset 2,0.05
set label "Method 3" at screen posX, posY-2*shiftY left offset 2,0.05
set label "Method 4" at screen posX, posY-3*shiftY left offset 2,0.05
set label "Reference" at screen posX, posY-4*shiftY left offset 2,0.05
# -----------------------------------------------
plot \
keyentry w filledcurves ls 1 title "Method 1",\
keyentry w filledcurves ls 2 title "Method 2",\
keyentry w filledcurves ls 3 title "Method 3",\
keyentry w filledcurves ls 4 title "Method 4",\
"datafile.dat" u 1:2:0 w boxes lc palette notitle,\
"" u 1:3:(0.5) w xerrorbars ls -1 pt -1 lw 3 title "Reference"
做这个剧情
还有其他方法吗?
还有别的办法吗?是的,但是有点难看。键样本的高度由用于键标题的字体大小决定。您可以通过将键设置为使用大字体然后覆盖每个情节标题的实际文本来滥用它。
以下示例将关键字体设置为 20 磅,并在撰写标题文本时使用增强文本模式将大小缩小回 10 磅。您可以忽略复杂的 using
和 every
位,这只是生成一些假数据进行绘图的一种方式。
set term pngcairo size 500,500 font "ArnoPro,10"
set output "boxes.png"
$DATA << EOD
5
2
4
3
1
EOD
set yrange [0:6]
set style fill solid 1.0 border lc "black"
set boxwidth 0.3
set key font "ArnoPro,20" enhanced
plot for [i=1:5] $DATA every ::(i-1)::(i-1) using (i):(column(1)) with boxes \
title sprintf("{/ArnoPro=10 Method %d}", i)
根据@Ethan 的解决方案,您还可以绘制超出范围或使用 NaN
.
plot for [i=1:5] NaN w l lw 13 lt i ti sprintf(" Method %d",i)
代码:
### enlarge height of key sample
reset session
$DATA << EOD
5
2
4
3
1
EOD
set yrange [0:6]
set style fill solid 1.0 border lc "black"
set boxwidth 0.3
set key samplen 2 reverse
plot for [i=1:5] $DATA every ::(i-1)::(i-1) using (i):(column(1)) with boxes \
title sprintf("Method %d", i), \
for [i=1:5] NaN w l lw 13 lt i ti sprintf(" Method %d",i)
### end of code
结果: