Arctan Binning, from chart to bar chart, tricks

Based on Sjoerd's excellent solution and extension to From Cartesian to Polar Histograms using Mathematica , consider the following:

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

As you can see, the histogram shows the rotational symmetry of what it should. I tried everything to get these direct, but failed. Without Reverse, this is the worst. I tried RotateRight without success. I feel the problem is in my BinCount. ArcTan outputs from -Pi to Pi, while Sjoerd suggested I go from 0 to 2Pi. But I do not understand how to do this.

EDIT: The problem is resolved. Thanks to Sjoerd, Belisarius, Heike's solutions, I can show a histogram of eye fix locations, given the center of gravity of the image.

enter image description here

+7
source share
2 answers

You can use the ChartElementFunction option to accurately position sectors. The first argument to ChartElementFunction is {{angleMin, angleMax}, {rMin,rMax}} . The first sector has boundaries {angleMin, angleMax} = {-Pi/12, Pi/12} , the second {Pi/12, 3 Pi/12} , etc. Therefore, to get the right rotation, you can do something like

 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]]]]]] 

enter image description here

+5
source

Just check now, but your first plot seems erroneous:

 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

Edit

I did not follow all your code, but the reflection in Screen Center seems to fix it:

 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

Edit

Here you can see a small misalignment in my code, which was solved in Haik (vote for it!)

 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

+6
source

All Articles