【发布时间】:2023-03-09 02:15:01
【问题描述】:
基于 Sjoerd,From Cartesian Plot to Polar Histogram using Mathematica 上的出色解决方案和扩展,请考虑以下内容:
list = {{21, 16}, {16, 14}, {11, 11}, {11, 12},
{13, 15}, {18, 17}, {19, 11}, {17, 16}, {16, 19}}
ScreenCenter = {20, 15}
ListPolarPlot[{ArcTan[##], EuclideanDistance[##]} & @@@ (# - ScreenCenter & /@ list),
PolarAxes -> True, PolarGridLines -> Automatic, Joined -> False,
PolarTicks -> {"Degrees", Automatic},
BaseStyle -> {FontFamily -> "Arial", FontWeight -> Bold,
FontSize -> 12}, PlotStyle -> {Red, PointSize -> 0.02}]
Module[{Countz, maxScale, angleDivisions, dAng},
Countz = Reverse[BinCounts[Flatten@Map[ArcTan[#[[1]] - ScreenCenter[[1]], #[[2]] -
ScreenCenter[[2]]] &, list, {1}], {-\[Pi], \[Pi], \[Pi]/6}]];
maxScale = 4;
angleDivisions = 12;
dAng = (2 \[Pi])/angleDivisions;
SectorChart[{ConstantArray[1, Length[Countz]], Countz}\[Transpose],
SectorOrigin -> {-\[Pi]/angleDivisions, "Counterclockwise"},
PolarAxes -> True,
PolarGridLines -> Automatic,
PolarTicks -> {Table[{i \[Degree] + \[Pi]/angleDivisions,i \[Degree]},
{i, 0, 345, 30}], Automatic},
ChartStyle -> {Directive[EdgeForm[{Black, Thickness[0.005]}], Red]},
BaseStyle -> {FontFamily -> "Arial", FontWeight -> Bold,
FontSize -> 12}, ImageSize -> 400]]
如您所见,直方图显示了应有的旋转对称性。 我想尽一切办法把这些弄明白,但没有成功。没有反向是最糟糕的。我试过 RotateRight 没有成功。我觉得问题出在我的 BinCount 上。 ArcTan 输出从 -Pi 到 Pi,而 Sjoerd 建议我需要从 0 到 2Pi。但我不明白该怎么做。
编辑:问题已解决。感谢 Sjoerd、Belisarius、Heike 解决方案,我能够在给定图像重心的情况下显示眼睛注视位置的直方图。
【问题讨论】:
-
@beliarius:当以
ArcTan[x,y]形式使用ArcTan时,范围为(-Pi,Pi] -
@belisarius,对不起,我现在很忙 :-(。谢谢你的帮助!
-
@500 注意Heike的解决方案,因为它似乎更好地匹配位置
-
我在您最初提出的这个问题上提供了答案。
-
@Sjoerd 也许我错了,但在我看来,您的极坐标直方图并不代表点密度。也许缺少对称变换。 (请参阅那里的答案中的 90 - 135 度范围)