You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Gnuplot柱状图是否支持Hypertext?如何自定义悬浮弹窗内容?

关于gnuplot柱状图鼠标悬浮Hypertext功能的疑问

我需要制作KPI的交互式内容评估,想要实现类似点样式(hypertext.dem)的鼠标悬浮弹窗功能,想咨询:柱状图目前或未来是否支持该功能?

我在SVG终端的图表中能看到显示using语句的默认弹窗,但无法通过"with labels hypertext"语句修改它。目前我想到的唯一解决方案是在柱状图上方叠加一个带点样式的图层来实现Hypertext弹窗,已在gnuplot 6.0和6.0.2版本中进行测试,以下是我的脚本(包含theozh的建议):

reset session
set datafile separator ","
set xtics nomirror rotate by 0
set style data histogram
set style histogram rowstacked title textcolor lt -1
set boxwidth 0.75
set style fill solid 0.3 border
unset key
set key noautotitle

# 我需要一个查找表,为第6列及之后每3列直到23*3列的KPI显示相关文本
array Cat[4000]
Cat[1]=''
Cat[1110]='Text 1110'
Cat[1122]='this means something 1122'
Cat[1123]='this means sth different 1123'
Cat[1124]='this yet means sth slightly different 1123'
Cat[2242]='Here some more text 2242'
Cat[2230]='Here some more text 2230'
Cat[3340]='has another meaning 3340'
Cat[4000]='Text_4000'
Cat2label(position) = sprintf("%d\n%s", column(position),Cat[column(position)])

set output "KPI_2025_02.svg"
set term svg size 1280,300 mousing jsdir './js/'

set style histogram rowstacked title textcolor lt -1

# 这里用了多图布局,因为还有其他内容(此处无关)
set multiplot layout 1,2
set bmargin 1.6

set size 0.85,1.000000
set origin 0,0.000000

# 绘制堆叠竖条(最高到24小时,x轴为日期),同时绘制KPI短文本作为标签
p [-0.5:31.5][0:24]\
  for [i=0:23] "datafile_gp.dat" u i*3+4:i*3+5:xtic(sprintf("%02d",$3)) lc variable, \
  for [i=0:23] "datafile_gp.dat" u :(((Cat2label(i*3+6))!=1) ? (sum [k=0:i] column(3*k+4)) : 3/0):i*3+6 w labels font "arial,8" tc rgb "black" offset -0.1,-0.25

set size 0.85,1.000000
set origin 0.0,0.000000

# 这是生成Hypertext弹窗的关键部分:
p [-0.5:31.5][0:24]\
  for [i=0:23] "datafile_gp.dat" u ($0+0.4):(((Cat2label(i*3+6))!="1") ? (sum [k=0:i] column(k*3+4))-0.5 : 3/0):(Cat2label(i*3+6)):i*3+5 lc variable with labels hypertext point pt 5 ps 0.5

unset multiplot

需要保存为datafile_gp.dat的数据文件内容:

2025,02,01,24.0,3,2242, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1
2025,02,02,24.0,3,2242, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1
2025,02,03, 6.0,3,2242, 1.0,3,2230, 5.0,2,1110, 3.0,2,1122, 2.0,3,2230, 7.0,3,2242, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1
2025,02,04, 6.0,3,2242, 1.0,3,2230, 3.0,2,1122, 2.0,2,1123, 1.0,1,3340, 1.0,2,1124, 2.0,2,1110, 1.0,2,1122, 7.0,3,2242, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1, 0.0,0,   1

内容的提问来源于stack exchange,提问作者Joe_Oldstyle

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 21:47:02