在 Mathematica 中自定义绘图背景

发布于 2024-12-03 01:12:50 字数 1199 浏览 1 评论 0原文

考虑:

ListPlot[Range[10], 
         Background -> Gray, 
         PlotLabel -> "I don`t want the background here !"]

在此处输入图像描述

有没有办法将背景仅应用于实际绘图区域?

不在轴上,不在标签后面。那么在这种情况下基本上是矩形 {{0,0},{10,10}} 吗?

编辑:我们可以使用 PolarListPlot 做同样的事情吗?

使用 Sjoerd 解决方案使用 Mathematica 从笛卡尔图到极坐标直方图

dalist = {{21, 22}, {26, 13}, {32, 17}, {31, 11}, {30, 9}, 
          {25,12}, {12, 16}, {18, 20}, {13, 23}, {19, 21}, 
          {14, 16}, {14,22}, {18, 22}, {10, 22}, {17, 23}}

ScreenCenter = {20, 15}

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

在此处输入图像描述

Considering:

ListPlot[Range[10], 
         Background -> Gray, 
         PlotLabel -> "I don`t want the background here !"]

enter image description here

Is there any way to have the background applied solely to the actual plotting zone?

Not on the axis, not behind the label. So basically to the rectangle {{0,0},{10,10}} in that case?

EDIT: Can we do the Same using PolarListPlot?

Using Sjoerd Solution on From Cartesian Plot to Polar Histogram using Mathematica:

dalist = {{21, 22}, {26, 13}, {32, 17}, {31, 11}, {30, 9}, 
          {25,12}, {12, 16}, {18, 20}, {13, 23}, {19, 21}, 
          {14, 16}, {14,22}, {18, 22}, {10, 22}, {17, 23}}

ScreenCenter = {20, 15}

ListPolarPlot[{ArcTan[##],EuclideanDistance[##]} & @@@ (# - ScreenCenter & /@ dalist), 
               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

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

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

发布评论

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

评论(4

思念绕指尖 2024-12-10 01:12:50

你可以这样做:

ListPlot[Range[10], PlotLabel -> "I don`t want the background here !",
  Frame -> {True, True, False, False}, AxesOrigin -> {0, 0}, 
 Prolog -> {Gray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}]

在此处输入图像描述

You could do something like this:

ListPlot[Range[10], PlotLabel -> "I don`t want the background here !",
  Frame -> {True, True, False, False}, AxesOrigin -> {0, 0}, 
 Prolog -> {Gray, Rectangle[Scaled[{0, 0}], Scaled[{1, 1}]]}]

enter image description here

无悔心 2024-12-10 01:12:50

您可以使用 Labeled

Labeled[
  ListPlot[Range[10], Background -> Gray,
  PlotLabel -> "I don`t want the background here !"],
  "So place the label here", Top]

You could use Labeled as in

Labeled[
  ListPlot[Range[10], Background -> Gray,
  PlotLabel -> "I don`t want the background here !"],
  "So place the label here", Top]
黄昏下泛黄的笔记 2024-12-10 01:12:50
ListPlot[Range[10], 
         Background -> Gray, 
         PlotLabel -> Style["I don`t want the background here !",
                            Background -> White ]]

结果

ListPlot[Range[10], 
         Background -> Gray, 
         PlotLabel -> Style["I don`t want the background here !",
                            Background -> White ]]

result

赏烟花じ飞满天 2024-12-10 01:12:50

你可以这样做:

Show[Graphics[{Pink, Rectangle[{0, 0}, {10, 10}]}], 
 ListPlot[Range[10]], Axes -> True, AspectRatio -> 1/2]

在此处输入图像描述

编辑

也许更好

c = RandomInteger[100, 10];
ListPlot[c,  Prolog -> {Pink, Rectangle[{0, Min@c}, {Length@c, Max@c}]}]

You could do:

Show[Graphics[{Pink, Rectangle[{0, 0}, {10, 10}]}], 
 ListPlot[Range[10]], Axes -> True, AspectRatio -> 1/2]

enter image description here

Edit

Perhaps better

c = RandomInteger[100, 10];
ListPlot[c,  Prolog -> {Pink, Rectangle[{0, Min@c}, {Length@c, Max@c}]}]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文