Plot 根据列中的值绘制新系列

Plot 根据列中的值绘制新系列,plot,gnuplot,Plot,Gnuplot,假设我们有如下数据: 1383.77224864627 1910.27446956287 13 2022.08962783969 1870.75968662608 13 2244.59435149955 2334.43843428841 13 3223.73010669775 2409.90834407782 15 708.364446053354 3199.82702811616 15 1190.6942303025 2634

假设我们有如下数据:

1383.77224864627    1910.27446956287    13
2022.08962783969    1870.75968662608    13
2244.59435149955    2334.43843428841    13
3223.73010669775    2409.90834407782    15
708.364446053354    3199.82702811616    15
1190.6942303025     2634.33363259192    15
1749.15599203783    2716.76870380272    19
2227.80906774024    3119.99529267007    19
是否可以根据第3列中的值绘制序列

本例中的理想结果是在一个绘图上有3个不同颜色的系列

我知道我可以通过以下方式创建新系列:

plot 'datafile' using col1:col2, '' using col1:col3
或者在数据文件中的系列之间使用新行,但我不想这样做

谢谢!
编辑:我使用的是gnuplot 5.0版

您需要先过滤数据文件,然后分别绘制各个部分:

#prepare the command responsible for filtering the data file of interest
#select all rows the value in the 3rd column of which is equal to val
filterData(fname, val)=sprintf("<gawk '$3==%d' %s", val, fname)

#show individual dependencies in one plot
plot for [sval in "13 15"] \
    filterData('datafile.dat', int(sval)) w lp t sprintf('value %s', sval)
这将给你:

您需要先过滤数据文件,然后分别绘制各个零件:

#prepare the command responsible for filtering the data file of interest
#select all rows the value in the 3rd column of which is equal to val
filterData(fname, val)=sprintf("<gawk '$3==%d' %s", val, fname)

#show individual dependencies in one plot
plot for [sval in "13 15"] \
    filterData('datafile.dat', int(sval)) w lp t sprintf('value %s', sval)
这将给你:

基于我对您的需求的理解,这将有助于:

set palette defined ( 13 "blue", 15 "red", 19 "green")
unset key
unset colorbox
plot [500:3500][1800:3500] "x" u 1:2:3 with points palette ps 3 pt 5
产生

编辑:

还可以定义一个连续的调色板,并根据其在该比例内的值分配实际颜色。实际上:

set palette defined ( 0 "blue", 20 "green", 40 "red")
unset key
set colorbox                              # for demo purpose
plot [500:3500][1800:3500] "x" u 1:2:3 with points palette ps 3 pt 7
带来

对于给定的数据集。添加新系列时,颜色将发生变化。

基于我对您所需内容的理解,这将有助于:

set palette defined ( 13 "blue", 15 "red", 19 "green")
unset key
unset colorbox
plot [500:3500][1800:3500] "x" u 1:2:3 with points palette ps 3 pt 5
产生

编辑:

还可以定义一个连续的调色板,并根据其在该比例内的值分配实际颜色。实际上:

set palette defined ( 0 "blue", 20 "green", 40 "red")
unset key
set colorbox                              # for demo purpose
plot [500:3500][1800:3500] "x" u 1:2:3 with points palette ps 3 pt 7
带来


对于给定的数据集。添加新系列时,颜色将发生变化。

您是说希望x轴上有col3,y轴上有COL1和col3吗?如果没有,请解释结果应该是什么样子。我想画一个散点图,其中第一列和第二列是x,y,第三列值区分一个系列。使用问题中的示例,我希望绘制一个3系列的点-每个系列具有不同的颜色-3个点来自系列“13”,3个点来自系列“15”,2个点来自系列“19”。有帮助吗?您是说希望col3位于x轴上,cols 1和3位于y轴上吗?如果没有,请解释结果应该是什么样子。我想画一个散点图,其中第一列和第二列是x,y,第三列值区分一个系列。使用问题中的示例,我希望绘制3个点系列-每个系列具有不同的颜色-3个点来自系列“13”,3个点来自系列“15”,2个点来自系列“19”。是否有帮助?这正是我想要实现的,但没有办法不使用自定义调色板?我有25个可能的系列,所以我需要定义一个全新的调色板,每次由25种颜色组成?参见编辑后的示例,尽管我想知道这样的绘图是否足够清晰-但这是你的要求…我在你的帖子中没有看到任何更改。这将是一个集群着色图,所以它会很好地工作:正如你所说的,比例不起作用-太多相似的颜色:很好的颜色列表使用。谢谢这正是我想要实现的,但没有办法不使用自定义调色板?我有25个可能的系列,所以我需要定义一个全新的调色板,每次由25种颜色组成?参见编辑后的示例,尽管我想知道这样的绘图是否足够清晰-但这是你的要求…我在你的帖子中没有看到任何更改。这将是一个集群着色图,所以它会很好地工作:正如你所说的,比例不起作用-太多相似的颜色:很好的颜色列表使用。谢谢