向 gnuplot 中的标签添加彩色线条?
Add a coloured line to a label in gnuplot?
我想知道是否可以在 gnuplot 的标签命令中添加彩色线条?也就是说,假设我想在标签命令中的一些文本后添加一条红线:
set label "some text here which is then followed by a red horizontal line -----" at 100,200 front
基本上,我想在标签命令中模仿 gnuplot 中密钥的通常表示。我已经有一个键,在同一个绘图环境中不允许使用另一个键,所以我想通过标签命令手动构造第二个键。
提前致谢。
您可以通过绘制全部无效的数据(NaN,而不是数字)来获得第二个密钥。例如,
cat >data <<\!
17 15
18 5
19 10
21 7
!
gnuplot -persist <<\!
plot "data" u 1:2 with lines title "plot1", \
"" u (NaN):(NaN) with lines title "plot2"
!
我会按照以下方式进行。检查 help arrow
和 help label
.
的详细信息
编辑: 使用单独的行和标签当然是更多的代码,但你有充分的灵活性。我想这取决于你到底想做什么。
代码:
### labels with lines
reset session
set size ratio -1
set arrow 1 from 4,0 to 7,0 lc "red" lw 2 nohead
set label 1 at 4,0 "Some text" right offset -1,0
set arrow 2 from 2,-2 to 5,-2 lc "red" lw 2 dt 3 nohead
set label 2 at 5,-2 "Some text" left offset 1,0
set arrow 3 from -6,5 to -2,5 lc "red" lw 2 dt 1 nohead
set label 3 at -4,5 "Some text" center offset 0,-1
set arrow 4 from -6,-2 length 5.5 angle 45 lc "red" lw 2 dt 3 nohead
set label 4 at -6,-2 "Some text" font ",14" right rotate by 45 offset -1,0
plot x w l lc "blue"
### end of code
结果:
您可以使用带有关键字 keyentry
而不是文件名的 plot 子句来生成额外的标题和 line/point/fill 示例作为密钥。您还可以使用关键字 at <x-pos>,<y-pos>
将此额外标题放置在页面的其他位置。
来自 on-line 演示集的示例:
此处为快速示例:
set xrange [0:20]
plot x**2, x**3, \
keyentry with lines dt '-' lc "red" title "Extra title" at graph 0.25, graph 0.75
我想知道是否可以在 gnuplot 的标签命令中添加彩色线条?也就是说,假设我想在标签命令中的一些文本后添加一条红线:
set label "some text here which is then followed by a red horizontal line -----" at 100,200 front
基本上,我想在标签命令中模仿 gnuplot 中密钥的通常表示。我已经有一个键,在同一个绘图环境中不允许使用另一个键,所以我想通过标签命令手动构造第二个键。
提前致谢。
您可以通过绘制全部无效的数据(NaN,而不是数字)来获得第二个密钥。例如,
cat >data <<\!
17 15
18 5
19 10
21 7
!
gnuplot -persist <<\!
plot "data" u 1:2 with lines title "plot1", \
"" u (NaN):(NaN) with lines title "plot2"
!
我会按照以下方式进行。检查 help arrow
和 help label
.
编辑: 使用单独的行和标签当然是更多的代码,但你有充分的灵活性。我想这取决于你到底想做什么。
代码:
### labels with lines
reset session
set size ratio -1
set arrow 1 from 4,0 to 7,0 lc "red" lw 2 nohead
set label 1 at 4,0 "Some text" right offset -1,0
set arrow 2 from 2,-2 to 5,-2 lc "red" lw 2 dt 3 nohead
set label 2 at 5,-2 "Some text" left offset 1,0
set arrow 3 from -6,5 to -2,5 lc "red" lw 2 dt 1 nohead
set label 3 at -4,5 "Some text" center offset 0,-1
set arrow 4 from -6,-2 length 5.5 angle 45 lc "red" lw 2 dt 3 nohead
set label 4 at -6,-2 "Some text" font ",14" right rotate by 45 offset -1,0
plot x w l lc "blue"
### end of code
结果:
您可以使用带有关键字 keyentry
而不是文件名的 plot 子句来生成额外的标题和 line/point/fill 示例作为密钥。您还可以使用关键字 at <x-pos>,<y-pos>
将此额外标题放置在页面的其他位置。
来自 on-line 演示集的示例:
此处为快速示例:
set xrange [0:20]
plot x**2, x**3, \
keyentry with lines dt '-' lc "red" title "Extra title" at graph 0.25, graph 0.75