【问题标题】:gnuplot x label position in histogramgnuplot x 直方图中的标签位置
【发布时间】:2014-04-04 15:53:29
【问题描述】:

我有以下数据:

t_4 24 3 0 0
t_6 37 4 0 0
t_8 51 4 2 0 

t_4 15 1 0 0
t_6 21 0 0 1
t_8 30 0 0 1

t_4 13 2 1 0
t_6 20 3 1 0
t_8 22 4 1 0

我尝试使用此代码的修改版本制作类似于此 http://www.bmsc.washington.edu/people/merritt/gnuplot/stack+cluster.dem 的直方图:

set style data histogram
set style histogram rowstacked
set style fill solid
set boxwidth 0.5
set key invert samplen 0.2
set key samplen 0.2
set bmargin 3
set offset 0,2,0,0

set title "number of multiple resonances"

plot newhistogram "1:j" lt 1, \
     'stack+cluster.dat' index 0 u 2:xtic(1) title "one", \
     '' index 0 u 3 title "two", \
     '' index 0 u 4 title "three", \
     '' index 0 u 5 title "four"

     newhistogram "2:j" lt 1, \
     'stack+cluster.dat' index 1 u 2:xtic(1) notitle, \
     '' index 1 u 3 notitle, \
     '' index 1 u 4 notitle, \
     '' index 1 u 5 notitle

      newhistogram "3:j" lt 1, \
     'stack+cluster.dat' index 1 u 2:xtic(1) notitle, \
     '' index 1 u 3 notitle, \
     '' index 1 u 4 notitle, \
     '' index 1 u 5 notitle

但这是我找到的输出

如您所见,问题在于 x 标签名称 newhistogram "1:j""2:j""3:j":我只能看到“1:j”并与“t_4...”重叠。

有人可以帮帮我吗?

【问题讨论】:

    标签: gnuplot histogram


    【解决方案1】:

    那个脚本出错了!所有命令必须属于单个plot 命令。正如你所拥有的,脚本在第二个 newhistogram 之前终止。

    接下来的事情是,您需要用 两个 空行分隔两个块,以便使用 index 参数来处理它们(对此另请参阅数据文件 @987654321 中的 cmets @属于你讲的例子)。

    通过这些更正,您将获得以下脚本(另请注意 title offset):

    set style data histogram
    set style histogram rowstacked title offset 0,-1
    set style fill solid
    set boxwidth 0.5
    set key invert samplen 0.2
    set key samplen 0.2
    set bmargin 3
    set offset 0,2,0,0
    
    set title "number of multiple resonances"
    
    plot newhistogram "1:j" lt 1, \
         'stack+cluster.dat' index 0 u 2:xtic(1) title "one", \
         '' index 0 u 3 title "two", \
         '' index 0 u 4 title "three", \
         '' index 0 u 5 title "four",\
         newhistogram "2:j" lt 1, \
         'stack+cluster.dat' index 1 u 2:xtic(1) notitle, \
         '' index 1 u 3 notitle, \
         '' index 1 u 4 notitle, \
         '' index 1 u 5 notitle,\
          newhistogram "3:j" lt 1, \
         'stack+cluster.dat' index 1 u 2:xtic(1) notitle, \
         '' index 2 u 3 notitle, \
         '' index 2 u 4 notitle, \
         '' index 2 u 5 notitle
    

    结果(使用 4.6.5):

    【讨论】:

    • 乍一看我并不清楚。神奇之处在于:set style histogram rowstacked title offset 0,-1
    猜你喜欢
    • 2022-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-07
    • 1970-01-01
    • 2018-05-25
    相关资源
    最近更新 更多