【问题标题】:Changing bar colors on bar graphs with gnuplot使用 gnuplot 更改条形图上的条形颜色
【发布时间】:2018-07-17 21:43:33
【问题描述】:

我正在使用 gnuplot 绘制条形图。

这是我的结果图:

问题是:我希望每个条都有不同的颜色。例如:红色的 MSA-GA ACO 和蓝色的 MSA-GA PACO。

我该怎么做?

以下是我使用过的命令:

set yrange [0:14000]  
set style fill solid
set boxwidth 0.7
set xtics format ""
set grid ytics
set title "Total Runtime"
set ylabel "Time (s)"
unset key
plot "data.dat" u 1:3:xtic(2) with boxes, "" u 1:3:3 with labels offset char 0,0.7

“data.dat”:

0 "MSA-GA ACO"       12726.38
1 "MSA-GA PACO"      5290.00

【问题讨论】:

    标签: gnuplot bar-chart


    【解决方案1】:

    您可以将linecolor variableboxes 绘图样式一起使用。唯一要记住的是你不能改变linetype 0的颜色,所以我给你的数据文件第一列的值加1来选择颜色id:

    set yrange [0:14000]  
    set style fill solid
    set boxwidth 0.7
    set xtics format ""
    set grid ytics
    set title "Total Runtime"
    set ylabel "Time (s)"
    unset key
    set linetype 1 lc rgb "red"
    set linetype 2 lc rgb "blue"
    plot "data.dat" u 1:3:($1+1):xtic(2) with boxes linecolor variable
    

    【讨论】:

      猜你喜欢
      • 2012-08-26
      • 1970-01-01
      • 1970-01-01
      • 2011-08-03
      • 2012-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-18
      相关资源
      最近更新 更多