gpt4 book ai didi

wolfram-mathematica - Arctan Binning,从绘图到直方图,技巧

转载 作者:行者123 更新时间:2023-12-04 08:10:05 25 4
gpt4 key购买 nike

基于 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}]

enter image description here
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]]

enter image description here

如您所见,直方图显示了它应该具有的旋转对称性。
我想尽一切办法把这些弄明白,但没有成功。没有 Reverse 是最糟糕的。我尝试了 RotateRight 没有成功。我觉得问题出在我的 BinCount 上。
ArcTan 输出从 -Pi 到 Pi,而 Sjoerd 建议我需要从 0 到 2Pi。但我不明白该怎么做。


编辑:问题解决了。感谢 Sjoerd、Belisarius、Heike 解决方案,我能够显示给定图像重心的眼睛注视位置的直方图。

enter image description here

最佳答案

现在只是检查,但你的第一个情节似乎有缺陷:

list = {{21, 16}, {16, 14}, {11, 11}, {11, 12}, {13, 15}, 
{18, 17}, {19, 11}, {17, 16}, {16, 19}};
ScreenCenter = {20, 15};

Show[ListPlot[list, PlotStyle -> Directive[PointSize[Medium], Purple]],
Graphics[
{Red, PointSize[Large], Point[ScreenCenter],
Circle[ScreenCenter, 10]}],
AspectRatio -> 1, Axes -> False]

enter image description here
ListPolarPlot[{ArcTan[Sequence @@ ##], Norm[##]} &/@ (#-ScreenCenter & /@ list), 
PolarAxes -> True,
PolarGridLines -> Automatic,
Joined -> False,
PolarTicks -> {"Degrees", Automatic},
BaseStyle -> {FontFamily -> "Arial", FontWeight -> Bold, FontSize -> 12},
PlotStyle -> {Red, PointSize -> 0.02}]

enter image description here

编辑

我没有遵循你的所有代码,但屏幕中心的反射似乎解决了这个问题:
Module[{Countz, maxScale, angleDivisions, dAng}, 
Countz = BinCounts[
{ArcTan[Sequence @@ ##]} & /@ (# + ScreenCenter & /@ -list),
{-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]]

enter image description here

编辑

在这里,您可能会看到我的代码中的小错位,这在 Heike 的回答中已解决(投赞成票!)
Show[Module[{Countz, maxScale, angleDivisions, dAng}, 
Countz = BinCounts[{ArcTan[
Sequence @@ ##]} & /@ (# +
ScreenCenter & /@ -list), {-\[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]],
ListPlot[Plus[# - ScreenCenter] & /@ list/2.5,
PlotMarkers -> Image[CrossMatrix[10], ImageSize -> 10]]
]

enter image description here

关于wolfram-mathematica - Arctan Binning,从绘图到直方图,技巧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7457254/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com