【问题标题】:add horizontal line histogram gnuplot添加水平线直方图 gnuplot
【发布时间】:2012-11-09 22:25:24
【问题描述】:

我想在 gnuplot 的直方图中添加一条水平线,可以吗?

我的直方图在 x 轴上有: alea1 alea 2 alea3 nalea1 nalea 2 nalea 3 y 轴从 0 到 25。

在 22 处,我想添加一条水平线,从直方图的一端一直延伸到另一端。

【问题讨论】:

    标签: gnuplot histogram


    【解决方案1】:

    尝试添加

    , 22 title ""
    

    在你的 plot 命令结束时。适用于我的测试数据(文件“histo”):

    # Year  Red   Green  Blue
    1990    33    45     18
    1991    35    42     19
    1992    34    44     14
    1993    37    43     25
    1994    47    15     30
    1995    41    14     32
    1996    42    20     35
    1997    39    21     31
    
    plot "histo" u 2 t "Red" w histograms, "" u 3 t "Green" w histograms, "" u 4 t "Blue" w histograms, 22 title ""
    

    (取自 Philip K. Janert,Gnuplot in Action)

    【讨论】:

    • 我花了一点时间才弄清楚你在说什么。您可能想演示一个完整的绘图命令,以准确说明您的意思。
    • 完成,@mgilson。如果原始问题中没有数据,我总是觉得有点挑战。
    • notitletitle "" 干净一些
    【解决方案2】:

    添加水平线和/或垂直线的典型方法是使用arrow

    set arrow from x1,y1 to x2,y2 nohead linestyle ...
    

    对于水平线,y1 和 y2 将相同。根据您的问题,我有点不确定您所说的“22 岁”是什么意思,但我猜您的意思是您想在直方图顶部绘制线 y=22。如果是这种情况,请尝试此操作(在您的 plot 命令之前)。

    set arrow from graph 0,first 22 to graph 1,first 22 nohead lc rgb "#000000" front
    

    【讨论】:

    • 谢谢你们俩。我已经用箭头做到了。是否可以添加一条线和单词让我说出直方图中 y=22 处的线的含义,例如图例?
    • @AudreyLee-Gosselin -- 当然。就做set label "some text" at ...,...。但是,您也可以使用其他答案来做到这一点:plot <histogram_stuff>, 22 w lines title "some text" 将其实际放入情节键中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-07
    • 1970-01-01
    • 2021-12-15
    • 1970-01-01
    相关资源
    最近更新 更多