PolarTicks,Polar GridLines&背景定制

时间:2011-09-18 16:09:01

标签: graphics wolfram-mathematica

建立起来 From Cartesian Plot to Polar Histogram using Mathematica我想自定义R和theta轴:

请考虑:

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

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, {1, 2, 3, 4, 5}},
        PolarAxesOrigin -> {Pi/2, 5},
        PolarTicks -> {Table[{i \[Degree] + \[Pi]/angleDivisions, i \[Degree]}, 
                       {i, 0, 345, 30}], Range[5]}, 
        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

2 /我想添加一个45度彩色的“theta bar”(如图所示)。但是我用ppt做到了。我无法找到一种方法来保持表格以获得主要的θ轴并绘制另一种颜色不同的颜色。

enter image description here

3 /我无法使用Prolog将Customsize Backgroud in Plot within Mathematica上提供的解决方案改编为Polarplot。是否可以将图中外圈内的区域用灰色标记?

1 个答案:

答案 0 :(得分:3)

您可以使用Epilog为背景创建行和Prolog,例如

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, {1, 2, 3, 4, 5}},
  PolarAxesOrigin -> {Pi/2, 5}, 
  PolarTicks -> {Table[{i \[Degree] + \[Pi]/angleDivisions, 
      i \[Degree]}, {i, 0, 345, 30}], Range[5]}, 
  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]]]],
  Epilog -> {Red, Thick, Line[{{0, 0}, 5/Sqrt[2] {1, 1}}]},
  Prolog -> {Gray, Disk[{0, 0}, 5]}]]

sectorchart with line and gray background