gnuplot single plot in different colors

ぐ巨炮叔叔 提交于 2021-01-28 07:41:15

问题


I have a single column of data (say 100 samples):

plot 'file' using 1 with lines

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...

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 ?


回答1:


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.

Code:

### 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

Result:



来源:https://stackoverflow.com/questions/64481930/gnuplot-single-plot-in-different-colors

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