【问题标题】:Customsize Background in Plot within Mathematica在 Mathematica 中的绘图中自定义背景
【发布时间】:2011-09-04 15:28:41
【问题描述】:

考虑:

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

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

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

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

From Cartesian Plot to Polar Histogram using Mathematica 上使用 Sjoerd 解决方案:

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

【问题讨论】:

标签: background wolfram-mathematica plot customization


【解决方案1】:

你可以这样做:

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

【讨论】:

  • 啊,就是这样!尽管我有所有自定义选项,它仍然可以正常工作!谢谢!
  • 如果网格线是白色的,我很难将这种方法用于灰色背景。我怀疑GridLines 在概念上“落后”Prolog
  • @Verbeia 这是真的。文档说:“网格线始终绘制在所有图形下方”。我想一种解决方法是手动在主要刻度处画线,或者作为Epilog 或结合Show
  • @Verbeia 使用未记录的选项Method->{"GridLinesInFront"->True}
  • @Verbeia 另一种可能性是使用 Inset 并自动选择 GridLines: Show[Graphics[{Gray,Rectangle[Scaled[{0,0}],Scaled[{1,1}]]}],Graphics[Inset[Graphics[{},PlotRange->{{0,10},{0,10}},GridLines->Automatic,GridLinesStyle->{{Thick,White},{Thick,White}},Method->{"GridLinesInFront"->True}],Center,Center,Scaled[{1,1}]]],ListLinePlot[Range[10],PlotStyle->{Thick,Red}]]
【解决方案2】:

你可以使用Labeled

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

【讨论】:

    【解决方案3】:
    ListPlot[Range[10], 
             Background -> Gray, 
             PlotLabel -> Style["I don`t want the background here !",
                                Background -> White ]]
    

    【讨论】:

    • 我认为req是不在轴上,不在标签后面。
    • 谢谢 WReach,很抱歉我没说清楚,希望编辑能让它变得更好。我想要的只是绘图区的一些背景。
    【解决方案4】:

    你可以这样做:

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

    【讨论】:

    • 谢谢,但是现在我失去了所有的情节选项:-(。这是我试图应用它的地方。我不知道如果没有定义 allRTbyConsistency 和plotOptionsXX : Show[ Graphics[{LightGray, Rectangle[{0, 0}, {4.5, 1.6}]}], ListPlot[((Mean /@ (allRTbyConsistency[[All, #]] // Transpose)) & /@ Range[3]), plotOptionsXX["Total RT by Consistency", "Response Time Total", "Consistency Index", Lighter[Red, #] & /@ {.1, .5, .9}], Joined -> True, PlotRange -> {{0.5, 4.5}, {0.5, 1.6}}, Background -> White, Frame -> True], Axes -> True, AspectRatio -> 3/4 ]
    • 更好的选择:Show[Graphics[{Pink,Rectangle[{0,0},Scaled@{1,1}]}],ListPlot[Range[10]],Axes->True,AspectRatio->1/2,PlotLabel->"I don't want the background here !"].
    • 或者使用Prolog:ListPlot[Range[10],Axes->True,AxesOrigin->{0,0},AspectRatio->1/2,PlotLabel->"I don't want the background here !",Prolog->{Pink,Rectangle[{0,0},Scaled@{1,1}]}]
    猜你喜欢
    • 1970-01-01
    • 2011-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多