Gnuplot:设置第三个(彩色)点的范围 [英] Gnuplot: Setting the range of a third (colored) point

查看:79
本文介绍了Gnuplot:设置第三个(彩色)点的范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用gnuplot绘制颜色图时,我通常使用以下几行:

When plotting color-maps using gnuplot, I usually use the following lines:

  ...
  set palette rgbformulae 33,13,10
  plot "file.dat" using 1:2:3 with points pointtype '7' palette

通常,第三点的范围(出现在图例中)由gnuplot自动设置.但是我该如何改变呢?说我希望第三点的范围是0到1500.

Usually the range of the third point (appearing in the legend) is automatically set by gnuplot. But how can I change that? say I want the range of the 3rd point to be from 0 to 1500.

有什么建议吗?

推荐答案

这实际上是一个非常好的问题-假设您是要确定颜色条的范围(不是图例[即键]就是图例)通常没有该信息.

This is actually a really good question -- assuming you mean that you want the colorbar range to be determined (not the legend [i.e. key] -- the legend doesn't typically have that information).

我的第一个念头是set cbrange.这可能会做您想要的-

My first thought was set cbrange. This might do what you want --

set cbrange [0:1500]
set palette rgbformulae 33,13,10
plot "file.dat" u 1:2:3 w p pt 7 palette

但是,问题是超出范围点您想发生什么?"此解决方案将超出范围点,到达刻度的底部/顶部(例如,紫色表示负数,红色表示大于1500).我的下一个想法是,您应该可以通过set zrange [0:1500]剪切掉这些要点-但这是行不通的.此时,您至少有2个选项.

However, the question is then "What do you want to happen to out of range points?" This solution will move out of range points to the bottom/top of the scale (e.g. purple for negative numbers, red for numbers greater than 1500). My next thought was that you should be able to clip those points out by set zrange [0:1500] -- But that doesn't work. You have at least 2 options at this point.

选项1:使用splot:

set view map
set cbrange [0:1500]
set zrange [0:1500]
set palette rgbformulae 33,13,10
splot "file.dat" u 1:2:3 w p pt 7 palette

您的边界将比以前稍有不同,但这没什么大不了的.

Your borders will be slightly different than they were before, but that's no real big deal.

选项2:用三元运算符过滤(您已经从上一个问题中了解到):

Option 2: filter with the ternary operator (which you already know about from your previous question):

set cbrange [0:1500]
set palette rgbformulae 33,13,10
inrange(c)=((c>=0) && (c<=1500))? c : (1/0)
plot "file.dat" u 1:2:(inrange($3)) w p pt 7 palette

此外,对于绘制颜色图,您可能需要研究pm3d的绘制样式(image也可能适用).您可能需要稍微重组数据文件,但是绘制颜色图就是绘制样式的基础.

Also, for plotting color maps, you may want to look into the pm3d plotting style (image might work too). You might need to restructure your datafile slightly, but plotting color maps is that plotting style's bread-and-butter.

这篇关于Gnuplot:设置第三个(彩色)点的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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