当第三列等于零时,如何使点为一种颜色,否则在Gnuplot? [英] How to make points one color when a third column equals zero, and another color otherwise, in Gnuplot?

查看:218
本文介绍了当第三列等于零时,如何使点为一种颜色,否则在Gnuplot?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要根据一列中的颜色更改一行值的点颜色。数据:

I need to vary the point color for a row of values based on the color in one column. The data:

# x y z
1, 3, 0  
1, 5, 6  
3, 5, 2  
4, 5, 0

颜色应为一个值如果该列为零,并且如果第三列中的值不为零,则使用不同的颜色。

The color should be one value if the column is zero and a different color if the value in the third column is non-zero.

所以,我假设:

plot "./file.dat" u 1:2:3 with points palette

http://stackoverflow.com/a/4115001\">http://stackoverflow.com/a/4115001 将无法正常工作。

as found here: http://stackoverflow.com/a/4115001 will not quite work.

在上面的示例数据,gnuplot命令提供三种不同的颜色,而不是我正在寻找的两种颜色。

In the above example data, that gnuplot command provides three different colors instead of the two I'm looking for.

推荐答案

接近您想要的:

set palette model RGB defined ( 0 'red', 1 'green' )
plot[0:5][0:6] "file.dat" u 1:2:( $3 == 0 ? 0 : 1 ) with points palette

您可以进一步删除噪音:

You could go one step further and remove the "noise":

unset key
unset colorbox
plot[0:5][0:6] "file.dat" u 1:2:( $3 == 0 ? 0 : 1 ) with points pt 7 ps 3 palette

这篇关于当第三列等于零时,如何使点为一种颜色,否则在Gnuplot?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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