Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在gnuplot中向标签添加彩色线?_Plot_Label_Key_Gnuplot - Fatal编程技术网

在gnuplot中向标签添加彩色线?

在gnuplot中向标签添加彩色线?,plot,label,key,gnuplot,Plot,Label,Key,Gnuplot,我想知道是否可以在gnuplot中的label命令中添加一条彩色线?也就是说,假设我想在label命令中的某些文本后添加一条红线: 在100200前面设置标签“此处的一些文本,后面是一条红色水平线----” 基本上,我想在label命令中模拟gnuplot中键的通常表示。我已经有一个键,并且同一打印环境中不允许有另一个键,因此我希望通过label命令手动构造第二个键 提前感谢。您可以通过打印所有无效数据(NaN,不是数字)获得第二个键。比如说, cat >data <<\!

我想知道是否可以在gnuplot中的label命令中添加一条彩色线?也就是说,假设我想在label命令中的某些文本后添加一条红线:

在100200前面设置标签“此处的一些文本,后面是一条红色水平线----”

基本上,我想在label命令中模拟gnuplot中键的通常表示。我已经有一个键,并且同一打印环境中不允许有另一个键,因此我希望通过label命令手动构造第二个键


提前感谢。

您可以通过打印所有无效数据(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"
!

cat>data我会用下面的方法来做。检查
帮助箭头
帮助标签
的详细信息

编辑:使用单独的行和标签当然更符合代码要求,但您有充分的灵活性。我想这取决于你到底想做什么

代码:

### 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子句,而不是文件名来为键生成额外的标题和行/点/填充示例。您还可以使用关键字
at,
将此额外标题放置在页面的其他位置

在线演示集中的示例:

此处的快速示例:

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 

谢谢。如何调整第二个键的位置?假设我想要左上角的第一个键和右下角的第二个键?例如,您可以使用
set key left-top
轻松地移动这两个键,但要将它们放在不同的角落,需要
set multiplot
和两个单独的绘图命令,因此非常复杂。谢谢