不同颜色的 gnuplot 单图

gnuplot single plot in different colors

我有一列数据(比如 100 个样本):

plot 'file' using 1 with lines

但是这个数据是分段的:10 个点,然后是 10 个点,等等...我希望每 10 个点都以不同的颜色显示。我确实将它们过滤成 10 个单独的文件并使用

plot 'file.1' with lines, 'file.2' with lines...

但随后 X 轴变为 0..10 而不是 0..100,并且所有 10 个图表都堆叠在一起。有没有一种简单的方法可以做到这一点而不必生成虚假的 X 数据?

取决于您的详细数据格式...以下是我认为您所要求的。 您的“假 x 数据”称为伪列 0,检查 help pseudocolumns。您可以使用 lc var 更改的颜色,选中 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([=10=]/10)) w lp pt 7 lc var notitle
### end of code

结果: