gnuplot pm3d绘制三角形数据 [英] gnuplot pm3d plot triangle data

查看:194
本文介绍了gnuplot pm3d绘制三角形数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在三角形表面上绘制热图,坐标和热值用页面上显示的方法获得staff.aist.go.jp/a.noda/programs/ternary/ternary-en .html。



因此,我处理数据并获取数据文件的格式为:

xy val



其中 x y 是0到1之间的值, val 是一个整数,表示我需要显示的频率。



数据文件是这样的: http://tinyurl.com/lqsqtvv



和剧情脚本是这样的:

 #!/ usr / bin / gnuplot 

重置

设定终端pngcairo大小640,480
设定输出'heat_map_triangle.png'

设定边界线宽0
未设定tics
set bmargin 3
set lmargin 3
set rmargin 3
set tmargin 3

set dgrid3d
set pm3d map
#set pm3d ftriangles
set pm3d插值0,0
设置pm3d在bs

设置标签'Y'在0,-0.03中心
设置标签'Z'在1,-0.03中心
将标签'X'设置为0.5,0.886中心

设置样式线1 lt1 lw 3 pt -1 ps 1

#x
设置箭头1从0,0到1,0.0 nohead linestyle 1

#z
设置箭头11从1,0到0.50,0.866 nohead linestyle 1

#y
设置箭头21从0.50,0.866到0,0 nohead linestyle 1

splot./triangle.outusing 1:2:3

所以,我出去了情节



这不完全是我想要的...



我无法理解如何告诉pm3d不要填写不在数据文件中的区域(例如,在三角形之外)以及为什么三角形的上边缘比热图要高。



有没有办法以我想要的方式绘制数据?



在pm3d文档中说它可以留下空的空格,但怎么做?

谢谢
<最终,为了pm3d的工作,gnuplot要求数据在某种网格mesh上。网格需要由四极管组成,但这是唯一的规定。例如,你的gridpoints可以像这样安排:

  1 
2
3
4 5 6 10
9
8
7

在这种情况下,gnuplot将从点1-2-4-5和点2-3-5-6等创建一个四边形。等等。Gnuplot将根据角色着色 c >选项 pm3d 。默认情况下,它使用单元格边角的4个值的平均值。



要将它放入数据文件中,您需要像这样的数据文件坐标:

  x1 y1 z1 
x2 y2 z2
x3 y3 z3
x10 y10 z10

x4 y4 z4
x5 y5 z5
x6 y6 z6
x10 y10 z10

x7 y7 z7
x8 y8 z8
x9 y9 z8
x10 y10 z10

请注意,我在横向扫描数据。 (当然,我们也可以对数据文件进行结构化,以便对数据进行垂直扫描)。我也在我的三角形的右顶点重复了一个点,以给它一个尖锐的点。这不是绝对必要的,但我想证明这是可能的。

您的数据不是这种形式,通常情况下,gnuplot会给您一个错误,指出您的数据没有网格化。然而,你已经添加了一行 set dgrid3d ,它告诉gnuplot你的数据不在网格上,而gnuplot应该使用反距离加权函数来插入数据到一个网格。不幸的是,gnuplot创建了一个规则(矩形)的网格,并且无法告诉它创建其他类型的网格。最终,你需要弄清楚如何将数据转化为这种形式。


i'm trying to plot an heatmap on a triangular surface, the coordinates and "heat values" are obtained with the methog shown on page staff.aist.go.jp/a.noda/programs/ternary/ternary-en.html.

so, i process the data and obtain a data file in the form:

x y val

where x and y are values between 0 and 1, and val is an integer representing the frequency i need to show.

the data file is this: http://tinyurl.com/lqsqtvv

and the plot script is this:

#!/usr/bin/gnuplot

reset

set terminal pngcairo size 640,480
set output 'heat_map_triangle.png'

set border linewidth 0
unset tics
set bmargin 3
set lmargin 3
set rmargin 3
set tmargin 3

set dgrid3d
set pm3d map
#set pm3d ftriangles
set pm3d interpolate 0,0
set pm3d at bs

set label 'Y' at 0, -0.03 center
set label 'Z' at 1, -0.03 center
set label 'X' at 0.5, 0.886 center

set style line 1 lt 1 lw 3 pt -1 ps 1

# x
set arrow 1 from 0,0 to 1, 0.0 nohead linestyle 1

# z
set arrow 11 from 1, 0 to 0.50, 0.866 nohead linestyle 1

# y
set arrow 21 from 0.50, 0.866 to 0,0 nohead linestyle 1

splot "./triangle.out" using 1:2:3

so, i'm getting out this plot

that is not exactly what i wanted...

i can't understand how to tell pm3d not to fill zones that are not in the data file (e.g. outside the triangle) and why the triangle top edge is taller than the heatmap.

it there a way to plot the data the way i want it?

in pm3d documentation it says that it can leave empty spaces, but how?

thanks

解决方案

Ultimately, for pm3d to work, gnuplot requires that the data be on some sort of grid "mesh". The mesh needs to composed of quadrillaterals, but that is the only stipulation. e.g., your gridpoints could be arranged like this:

 1
        2
                 3
 4      5        6     10
                 9
        8
 7

In this case, gnuplot will create a quadrilateral from points 1-2-4-5 and points 2-3-5-6, etc. etc. Gnuplot will color the quadrilateral depending on the corners2color option of pm3d. By default, it uses the average of the 4 values on the corners of the cells.

To put this in a datafile, you'd want to the datafile coordinates like this:

 x1   y1   z1
 x2   y2   z2
 x3   y3   z3
 x10  y10  z10

 x4   y4   z4
 x5   y5   z5
 x6   y6   z6
 x10  y10  z10

 x7   y7   z7
 x8   y8   z8
 x9   y9   z8
 x10  y10  z10

Notice how I left a blank line between horizontal "scans" across the data. (Of course, we could have structured the datafile to take vertical "scans" across the data as well). I also repeated a point at the right vertex of my triangle to give it a sharp point. This isn't strictly necessary, but I wanted to demonstrate it was possible.

Your data isn't in that form and normally, gnuplot would give you an error complaining that your data wasn't gridded. however, you've added the line set dgrid3d which tells gnuplot that your data isn't on a grid and that gnuplot should use an inverse distance weighting function to interpolate your data onto a grid. Unfortunately, gnuplot creates a regular (rectangular) grid and there is no way to tell it to create some other kind of grid. Ultimately, you need to figure out how to beat your data into this form.

这篇关于gnuplot pm3d绘制三角形数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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