Dynamically colored bar charts in Gnuplot?

情到浓时终转凉″ 提交于 2020-07-10 10:28:29

问题


Without choosing the color explicitly like Different coloured bars in gnuplot bar chart? is there a way for GNU plot to choose some distinguished colors based on the key (like a hash?)?

# git rev-list --count master
$commits << EOD
gecko 716280
webkit 226748
blink 906439
EOD

set terminal png
set yrange [0:*]      # start at zero, find max from the data
set boxwidth 0.5      # use a fixed width for boxes
unset key             # turn off all titles
set style fill solid  # solid color boxes
set title 'commits'
plot '$commits' using 2:xtic(1) with boxes

Bonus: Instead of 1x10^6 (which I find odd), could it simple say 716k, 227k, 906k. I.e. the scale is in the 1000s for the Y axis.


回答1:


The solution provided in Different coloured bars in gnuplot bar chart? works also without defining the linetypes. Gnuplot will use the default ones.

set yrange [0:*]      # start at zero, find max from the data
set boxwidth 0.5      # use a fixed width for boxes
unset key             # turn off all titles
set style fill solid  # solid color boxes
set title 'commits'
plot '$commits' using 0:2:($0+1):xtic(1) with boxes lc variable

You can also use one of the other predefined sequences of colors adding the following line:

set colors {default|classic|podo}


来源:https://stackoverflow.com/questions/62806241/dynamically-colored-bar-charts-in-gnuplot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!