根据列值改变多个数据块gnuplot的点颜色 [英] vary point color based on column value for multiple data blocks gnuplot

查看:57
本文介绍了根据列值改变多个数据块gnuplot的点颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与此问题非常相似,我从中学到了很多东西.但是,我正在处理多个数据块,如下所示:

My question is very similar to this one, from which I was able to learn a lot. However, I am working with multiple data blocks, like this:

1 2 3
4 5 6
7 8 0
4 3 0


4 5 7
2 3 0
4 5 0
5 6 7

我正在这样绘制它们:

plot "file.txt" index 0 u 1:2 w points pt 1,\
     "file.txt" index 1 u 1:2 w points pt 2

创建两个不同的点集,每个点都有不同的颜色.现在,我的目标是修改此脚本,以便如果第3个数据列为0,则该点的颜色将变为黑色.我想让其他要点保持它们当前的颜色(意思是彼此不同).我已经做到了:

which creates 2 different sets of points, each a different color. Now, my goal is to modify this script so that if the 3rd data column is 0, the color of the point will become black. I would like for the other points to remain the colors that they currently are though (meaning different from one another). I have done this:

set palette model RGB defined ( 0 'black', 1 'green' )
unset colorbox
plot file index 0 u 1:2:( $3 == 0 ? 0 : 1 ) w points pt 1 palette,\
     file index 1 u 1:2:( $3 == 0 ? 0 : 1 ) w points pt 2 palette

这完全符合我的要求,当然,现在两组都以绿色绘制.有什么方法可以根据需要绘制黑色的图形,但又可以使每个索引具有不同的颜色?

This does exactly what I want, except of course both sets are now plotted in green. Is there any way to plot the black ones as desired, but also make each index a different color?

推荐答案

它应该可以在调色板中定义一个额外的点:

It should work to define an extra point in the palette:

set palette model RGB defined ( 0 'black', 1 'green', 2 'red')
unset colorbox
plot file index 0 u 1:2:( $3 == 0 ? 0 : 1 ) w points pt 1 palette,\
     file index 1 u 1:2:( $3 == 0 ? 0 : 2 ) w points pt 2 palette

这篇关于根据列值改变多个数据块gnuplot的点颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆