【问题标题】:error while plotting stacked bar in gnuplot在 gnuplot 中绘制堆积条时出错
【发布时间】:2013-07-10 10:24:22
【问题描述】:

我正在尝试使用 gnuplot 绘制堆积条形图。例如,我尝试使用下面的数据和 gnuplot 代码绘制堆积条形图:

数据是:

year foo bar rest
1900 20 10 20
2000 20 30 10
2100 20 10 10

gnuplot 代码是:

#
# Stacked histograms
#
set term png size 300,300
set output 'stackedhisto.png'
#set title "Stacked histogram\nTotals"

# Where to put the legend
# and what it should contain
set key invert reverse Left outside
set key autotitle columnheader

set yrange [0:100]
set ylabel "total"

# Define plot style 'stacked histogram'
# with additional settings
set style data histogram
set style histogram rowstacked
set style fill solid border -1
set boxwidth 0.75

# We are plotting columns 2, 3 and 4 as y-values,
# the x-ticks are coming from column 1
plot 'stackedhisto.dat' using 2:xtic(1) \
    ,'' using 3 \
    ,'' using 4

当我执行上面的代码时,我得到了一些我不知道来源的错误。错误如下:

./script-plot-total-stacked-bar.gnu: line 25: syntax error near unexpected token `('
./script-plot-total-stacked-bar.gnu: line 25: `plot 'stackedhisto.dat' using 2:xtic(1) \'

此错误使我无法绘制自己的数据。我在 Ubuntu 11.10 中使用 gnuplot 4.6。 提前感谢任何帮助。 谢谢

注意:事实上这是在1 发布的。

【问题讨论】:

    标签: gnuplot


    【解决方案1】:

    我可以更正这个脚本。有一个拼写错误。我在

    行重新输入了连字符
    plot 'stackedhisto.dat' using 2:xtic(1) \
        ,'' using 3 \
        ,'' using 4
    

    抱歉,出错了。

    【讨论】:

      猜你喜欢
      • 2017-03-22
      • 1970-01-01
      • 2012-09-17
      • 2021-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-24
      相关资源
      最近更新 更多