在注意到https://lwn.net/Articles/723818/上的交互式 gnuplot 图形在鼠标悬停时显示国家/地区名称后,我想知道如何简单地显示图中点的值。
例如,我想将鼠标悬停在https://s.natalian.org/2020-08-24/mouse-hover.svg中的“daughter bar”上并清楚地看到60。
然而现在它只显示坐标 IIUC。我该如何解决?
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
Run Code Online (Sandbox Code Playgroud)
你正在寻找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
Run Code Online (Sandbox Code Playgroud)
结果:(Firefox 中 SVG 的屏幕截图。看起来我无法在此处放置 SVG,至少我不知道如何放置。)