gnuplot具有3D数据集中的热图的2D极坐标图-可能吗? [英] gnuplot 2D polar plot with heatmap from 3D dataset - possible?

查看:88
本文介绍了gnuplot具有3D数据集中的热图的2D极坐标图-可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用直角坐标绘制一个在3D中作为表面绘制的图,并在POLAR坐标中以2D在热图中查看它.这样做的原因是我正在获取该坐标系中某个系统上的数据.我只找到了一些相关的示例,但是在尝试使其与我的数据一起使用时陷入困境.我目前正在使用矩阵格式,如果可以帮助图表正常工作,我可以重新格式化数据集.

I'd like to take a plot that I have done as a surface in 3D using cartesian coordinates and view it as a heatmap in 2D in POLAR coordinates. The reason for this is I am obtaining data on a system in that coordinate system. I've only found some related examples, but am getting stuck trying to get it to work with my data. I am currently using the matrix format, and I can reformat the data set if this would help get the chart working.

数据是在扬声器上进行的SPL测量.麦克风被定位在相距固定距离(例如,固定半径)的位置,并且围绕整个扬声器水平地每10度进行一次测量.根据20Hz至20kHz的频率获得SPL测量值.

The data is SPL measurements taken on a loudspeaker. The microphone is positioned at a fixed distance away (e.g. fixed radius) and measurements are made at every 10 degrees around the entire loudspeaker horizontally. The SPL measurement is obtained as a function of frequency, 20Hz to 20kHz.

我想使用gnuplot创建2D极坐标图.频率将绘制为半径,扬声器周围的角度将为角度,高度"将为SPL电平.这应该生成一个表面,但是,我想创建一个热图pm3d,然后从上方查看(例如视图0,0)或作为2D图.我还需要添加显示SPL间隔的轮廓线,并将其叠加在热图上.

I would like to use gnuplot to create a 2D polar plot. Frequency would be plotted as the radius, the angle around the loudspeaker would be the angle, and the "height" would be the SPL level. This should generate a surface, however, I would like to create a heat map pm3d and then view that from above (e.g. view 0,0) or as a 2D plot. I also need to add contour lines that show intervals of SPL and superimpose that on the heat map.

我在这里发现了一些类似于笛卡尔坐标的东西: http://gnuplot-tricks.blogspot. com/2009/07/maps-contour-plots-with-labels.html 当我尝试将极坐标用于最终2D绘图时使用此方法时,我收到一条错误消息,极坐标图不支持带有图像"选项.有人可以尝试或确认吗?

I found something similar for cartesian coordinates here: http://gnuplot-tricks.blogspot.com/2009/07/maps-contour-plots-with-labels.html When I tried this approach using polar coordinates for the final 2D plot, I got an error message that the "with image" option is not supported for polar plots. Can someone try this or confirm this?

我已经能够使用散点图和正上方的视图(设置视图0.0)以3D形式将极地数据绘制为热图和等高线.如果我首先将现有的极坐标数据转换为笛卡尔坐标,则可能会得到类似于此网页所示的内容: 如何使用gnuplot创建3d极坐标图 我也可以从上方查看,但是我想添加到极坐标网格中,并具有角度和半径的标签.是我必须手动执行此操作,还是可以使用多图覆盖2D网格和从0.0开始查看的3D图?

I have been able to plot my polar data as a heatmap+contour lines in 3D using splot and view from directly above (set view 0.0). If I first convert my existing polar coordinate data into cartesian coordinates I will probably get something like what is shown in this web page: how to create a 3d polar graph with gnuplot I could view this from above, too, but I would like to add in the polar grid and have labels for the angle and radius. Would I have to do this manually or could I use multiplot to overlay a 2D grid and the 3D plot viewed from 0.0?

我不确定该如何处理.关于采取什么方向的任何建议将不胜感激.

I am not sure how to approach this. Any advice about what direction to take would be appreciated.

-查理

推荐答案

image绘图仅适用于均布的矩形网格,就像排列了任何位图图像一样.否则,必须将splotpm3d一起使用.

The image plotting works only for equally distributed rectangular grids, just like any bitmap image is arranged. Otherwise you must use splot with pm3d.

set grid polar仅适用于2D,因此必须使用multiplot将热图与极坐标网格叠加.下面是一个非常冗长的示例,向您展示它如何工作:

The set grid polar works only for 2D, so you must use multiplot to overlay your heatmap with the polar grid. Here a, quite lengthy, example to show you how it might work:

reset
set terminal pngcairo size 800,800
set output '3d-polar.png'

set lmargin at screen 0.05
set rmargin at screen 0.85
set bmargin at screen 0.1
set tmargin at screen 0.9

set pm3d map
unset key

set multiplot

# plot the heatmap
set parametric
set isosamples 500

unset border
unset xtics
unset ytics

set angles degree
r = 6
set urange[0:r] # radius
set vrange[0:360] # angle
set xrange[-r:r]
set yrange[-r:r]
set colorbox user origin 0.9,0.1 size 0.03,0.8
splot u*cos(v), u*sin(v), (cos(v)*besj0(2*u))**2

# now plot the polar grid only
set style line 11 lc rgb 'white' lw 2
set grid polar ls 11
set polar
set rrange[0:r]
unset raxis
set rtics format '' scale 0
unset parametric
set for [i=0:330:30] label at first (r+0.35)*cos(i), first (r+0.35)*sin(i)\
center sprintf('%d', i)
plot NaN w l
unset multiplot

结果是:

现在有一些技巧的详细信息:

And now some details about some tricks:

  • 为了获得平方尺寸,不能使用set size ratio 1,因为2D和3D图的边距不同,即使您指定了一些绝对边距也是如此.因此,我设置了一个方形画布大小(终端选项size 800,800),并设置了适当的绝对边距.

  • In order to get a square size, you can't use set size ratio 1, because the margins differ for the 2D and 3D plots, even if you would specify some absolute margins. Therefore, I set a square canvas size (terminal option size 800,800), and set appropriate absolute margins.

您不能unset rtics,因为这样网格就会消失.

You cannot unset rtics because then the grid would disappear.

网格标签必须手动设置.

The grid labels must be set manually.

颜色框也是手动设置的,因为否则它将与0标签重叠.

The colorbox was also set manually because otherwise it would have overlapped with the 0 label.

绘制NaN仅绘制网格

这篇关于gnuplot具有3D数据集中的热图的2D极坐标图-可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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