【问题标题】:Dynamically colored bar charts in Gnuplot?Gnuplot中的动态彩色条形图?
【发布时间】:2020-07-09 02:02:18
【问题描述】:

如果不像Different coloured bars in gnuplot bar chart? 那样明确选择颜色,GNU plot 是否可以根据键选择一些可区分的颜色(如哈希?)?

# 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

奖励:不是 1x10^6(我觉得很奇怪),而是简单地说 716k、227k、906k。 IE。 Y 轴的刻度为 1000 秒。

【问题讨论】:

  • help format specifier。命令set ytics format "%.0s%c" 将生成标签 100k 200k 300k ... 1M。

标签: gnuplot bar-chart


【解决方案1】:

Different coloured bars in gnuplot bar chart? 中提供的解决方案也可以在不定义线型的情况下工作。 Gnuplot 将使用默认的。

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

您还可以使用其他预定义的颜色序列之一,添加以下行:

set colors {default|classic|podo}

【讨论】:

  • 谢谢。所以看起来lc variable 是我所追求的魔法。
  • 我对@9​​87654323@还有一个问题
  • 你能解释一下0:2:($0+1) btw吗?
  • “lc 变量”需要 using 说明符中的最后一列,它标识用于绘制每一行的线型索引。每个线型都有自己的关联颜色。 $0 是行号,这里用来指定索引。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-04
  • 2018-10-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多