用绘图填充3D线下的区域 [英] Fill area below a line in 3D with splot

查看:70
本文介绍了用绘图填充3D线下的区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为每个围栏绘制带有多种颜色的3D围栏图".我的样本数据可以在这里找到:

I am plotting a 3D 'fence plot' with multiple colors for each fence. My sample data can be found here:

https://gist.github.com/anonymous/a926221ea96e92e86332

我使用以下方法绘制此数据:

I plot this data using this:

colors = "red red red red red"
splot for [i=1:words(colors)] 'input.sep.txt' index i u 2:1:3 w lines lc rgb word(colors,i)

画出的线条没有问题,我相信它们是正确绘制的.我的问题是:如何在线条下方填充,使其看起来像是坚固的墙(即一直向下到0 z值)?我尝试使用w pm3d,但是实际上并没有绘制出轴上可见的任何东西.

The lines are drawn without issue, and I believe they are drawn correctly. My question is this: how do I fill below the line so that it looks like a solid wall (i.e. all the way down to the 0 z value)? I tried using w pm3d, however this did not actually plot anything visible on the axis.

推荐答案

最好的选择是使用pm3d.为此,您必须稍稍更改数据文件:您必须重复一行,将重复项的z值更改为0并添加新行,即前两行数据

The best option you have is to use pm3d. For this to work you must change your data file a bit: You must duplicate very line, change the z-value of the duplicate to 0 and add a new line, i.e. your first two data lines

1 1 2
2 1 4

必须成为

1 1 2
1 1 0

2 1 4
2 1 0

,依此类推.以后,您仍然需要两个连续的空行来分隔不同的墙".

and so on. You still need the two consecutive empty lines later to separate different "walls".

如果您可以控制数据输出,则可以更改输出例程,也可以使用sed

If you have control over your data output, you could change your output routine, or you can use a command line tool like sed

sed 's/^\([0-9]* [0-9]* \)\(.*\)$/&\n\1 0\n/' gistfile1.txt

awk:

awk '1; {print $1,$2,0,"\n"}' gistfile1.txt

进行转换.当然,这可以从gnuplot中即时完成.然后,一个完整的,可运行的脚本是:

to do the conversion. Of course this can be done on-the-fly from within gnuplot. A complete, working script is then:

filename = 'gistfile1.txt'
sed = '< sed ''s/^\([0-9]* [0-9]* \)\(.*\)$/&\n\1 0\n/'' '

set autoscale cbfix
set palette defined (0 'red', 1 'blue')
set pm3d depthorder
unset colorbox
unset key
set ticslevel 0
splot sed.filename using 1:2:3:(column(-2)) with pm3d

,使用gnuplot 4.6.5和示例数据得到的结果是:

and the result using gnuplot 4.6.5 with your example data is:

一些附加说明:

  • 第四列用于选择与着色的z值不同的值.
  • column(-2)使用块编号(相邻的块由两个空行分隔)作为颜色索引.
  • 未连接属于不同数据块的点.
  • 使用set autoscale cbfix,您可以更好地控制飞机使用的颜色.
  • 如果您知道,例如三个应该具有特定颜色的飞机,您也可以使用set palette defined (0 'red', 1 'green', 2 'blue').
  • The fourth column is used to select a different value than the z-value for the coloring.
  • column(-2) uses the block number (adjacent blocks are delimited by two empty lines) as color index.
  • Points belonging to different data blocks aren't connected.
  • With set autoscale cbfix you can better control the colors used for the planes.
  • If you know, that you have e.g. three planes which should have specific colors you could also use set palette defined (0 'red', 1 'green', 2 'blue').

这篇关于用绘图填充3D线下的区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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