Gnuplot 绘制烛台图,但在键内使用一条线?

Gnuplot Plot a Candlesticks plot, but use a line inside the key?

我正在使用 C++ 程序通过 Gnuplot 自动绘制大量绘图。我正在使用烛台图样式制作箱线图,并根据手册中的示例通过添加修改后的烛台图来添加中位数和均值:

plot ’stat.dat’ using 1:3:2:6:5 with candlesticks title ’Quartiles’, \
’’              using 1:4:4:4:4 with candlesticks lt -1 notitle

这行得通,但键看起来很有趣,因为均值和中值在键中被绘制为矩形,即使它们在图上显示为线条。这是一个例子:

有没有简单的方法让按键显示线条而不是矩形?

可能的解决方案可能包括将均值和中值绘制为线而不是烛台,但我需要计算每个起点和终点的 X 位置。另一种解决方案可能包括使用标签和线条手动绘制密钥。但是这些可能很复杂而且不太灵活,所以我想问问是否存在任何更简单的解决方案。

您可以通过绘制 "invisible" 行来伪造密钥条目:

set terminal pngcairo
set output "candle_lines.png"

set boxwidth 0.4 relative
set xrange [0:4]
set yrange [0:100]

plot 'stat.dat' using 1:3:2:6:5 with candlesticks title 'Quartiles', \
     ''         using 1:4:4:4:4 with candlesticks lt -1 notitle,     \
     ''         using 1:7:7:7:7 with candlesticks lt  0 notitle,     \
     NaN        with lines title "Mean" lt -1,                       \
     NaN        with lines title "Median" lt 0

我的stat.dat:

1 40 50 63  65 70 57
2 50 60 67  75 80 63
3 30 40 53  55 60 47

结果: