gnuplot单个图以不同的颜色 [英] gnuplot single plot in different colors
问题描述
我只有一列数据(例如100个样本):
I have a single column of data (say 100 samples):
plot 'file' using 1 with lines
但是此数据被细分了:10个点,然后再增加10个,依此类推...我希望每10个块以不同的颜色显示.我确实将它们过滤为10个单独的文件并使用了
But this data is segmented: 10 points, then 10 more, etc... and I'd like each block of 10 to appear in a different color. I did filter them to 10 separate files and used
plot 'file.1' with lines, 'file.2' with lines...
但是X轴变为0..10而不是0..100,并且所有10个图形都被堆叠.有没有一种简单的方法,而不必生成虚假的X数据?
But then the X axis goes 0..10 instead of 0..100 and all 10 graphs are stacked. Is there a simple way to do that without having to generate fake X data ?
推荐答案
根据您的详细数据格式,以下内容正在执行我认为您要的操作.您的假X数据"称为伪列0,请检查 help伪列
.您可以使用 lc var
更改颜色,请检查 help linecolor变量
.
Depending on your detailed data format... the following is doing what I think you are asking for.
Your "fake x data" is called pseudocolumn 0, check help pseudocolumns
. The color you can change with lc var
, check help linecolor variable
.
代码:
### variable line color
reset session
# create some test data
set print $Data
do for [i=1:100] {
print sprintf("%g", rand(0)*i)
}
set print
plot $Data u 0:1:(int($0/10)) w lp pt 7 lc var notitle
### end of code
结果:
这篇关于gnuplot单个图以不同的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!