问题描述
注意到https://lwn.net/Articles/723818/上的交互式gnuplot图形在鼠标悬停时显示了国家名称之后,我想知道如何简单地显示图中点的值。
例如,我想将鼠标悬停在https://s.natalian.org/2020-08-24/mouse-hover.svg中的“女儿栏”上,并清楚地看到 60 。
set term svg mouse standalone
reset
$heights << EOD
dad 181
mom 170
son 100
daughter 60
EOD
unset key
set Boxwidth 0.5
set style fill solid
set yrange [0:*]
plot '$heights' using 2:xtic(1) with Boxes
set output '/tmp/mouse-hover.svg'
replot
解决方法
您正在寻找hypertext
,请选中help hypertext
。
您必须使用point
来锚定超文本。
玩点大小(此处为ps 3
)以更改鼠标将显示超文本的区域。
由于您可能不想在框的顶部显示彩色点,因此请使颜色透明,例如lc rgb 0xff123456
。
不幸的是,我还没有在gnuplot文档中找到任何使该超文本字体变大的方法。选项font ",30"
无效。如果您发现了,请告诉我。显然,您可以在wxt终端中执行此操作(请参见gnuplot: Hypertext with monospace?)。
代码:
### SVG standalone with hypertext
reset session
set term svg mouse standalone enhanced
set output 'tbSVGstandalone.svg'
$heights <<EOD
dad 181
mom 170
son 100
daughter 60
EOD
unset key
set boxwidth 0.5
set style fill solid
set yrange [0:*]
plot '$heights' u 2:xtic(1) w boxes,\
'' u 0:2:2 w labels hypertext point pt 7 ps 3 lc rgb 0xff123456
set output
### end of code
结果:(Firefox中的SVG屏幕快照。看来我无法在此处放置SVG,至少我不知道如何。)