Arctan Binning,从剧情到直方图,技巧

500*_*500 7 wolfram-mathematica bin

基于Sjoerd,使用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}]
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

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]]
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

如您所见,直方图显示了旋转对称性.我尝试了一切,以获得那些直,但没有成功.没有反向,这是最糟糕的.我试过RotateRight没有成功.我觉得问题出在我的BinCount中.ArcTan从-Pi输出到Pi,而Sjoerd建议我需要从0到2Pi.但我不明白该怎么做.

编辑:问题解决了.感谢Sjoerd,Belisarius,Heike解决方案,我能够在给定图像重心的情况下显示眼睛固定位置的直方图.

在此输入图像描述

Dr.*_*ius 6

刚刚检查,但你的第一个情节似乎有缺陷:

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]
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

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}]  
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

编辑

我没有按照你的所有代码,但屏幕中心的反思似乎解决了这个问题:

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]]
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

编辑

在这里你可能会看到我的代码中的小错位,这是在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]]
 ]
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


Hei*_*ike 5

您可以使用该ChartElementFunction选项准确定位扇区.第一个参数ChartElementFunction是形式{{angleMin, angleMax}, {rMin,rMax}}.第一个扇区有界限{angleMin, angleMax} = {-Pi/12, Pi/12},第二个界面{Pi/12, 3 Pi/12}等等.因此,要获得正确的旋转,你可以做类似的事情

Module[{Countz, maxScale, angleDivisions, dAng},
 maxScale = 4;
 angleDivisions = 12;
 dAng = (2 \[Pi])/angleDivisions;
 Countz = BinCounts[
   Flatten@Map[ArcTan @@ (# - ScreenCenter) &, list, {1}], 
    {-Pi, Pi, dAng}];

 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,

  ChartElementFunction -> 
   Function[{range}, Disk[{0, 0}, range[[2, 2]], - 11 Pi/12 + range[[1]]]]]]
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述