PolarTicks、Polar GridLines 和 PolarTicks背景定制

发布于 2024-12-05 10:59:28 字数 1758 浏览 5 评论 0原文

建立在 使用 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]]]]]]

在此处输入图像描述

2/我想添加一个45度角的“theta bar”(如图所示)。不过我是用ppt做到的。我找不到一种方法来保留表格来获取主θ轴并绘制另一个不同颜色的轴。

在此处输入图像描述

3/我未能适应 使用 Prolog 将 Mathematica 中的绘图中的背景自定义为极坐标图。是否可以将绘图外圆内的区域涂成灰色?

Building up on
From Cartesian Plot to Polar Histogram using Mathematica I would like to customize the R and theta Axes :

please consider :

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/I would like to add one "theta bar" colored at 45 Degree (as shown in the image). However I did that using ppt. I could not find a mean to keep the Table to get the main theta axes and draw another one colored differently.

enter image description here

3/I failed to adapt the solution provided on Customsize Backgroud in Plot within Mathematica to a Polarplot using Prolog. Is it possible to have the area within the outer circle of the plot colored in Gray let`s say ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

本王不退位尔等都是臣 2024-12-12 10:59:28

您可以使用 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]}]]

“带有线条和灰色背景的扇形图”

You could use Epilog to create the line and Prolog for the background, e.g.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文