【问题标题】:How to shade a plot in Mathematica如何在 Mathematica 中为绘图着色
【发布时间】:2012-01-04 02:48:22
【问题描述】:

我想生成如下图

我不确定如何生成阴影,即使我可以完成框架。我想知道在 Mathematica 的绘图中遮蔽某些区域的一般方法。请帮忙。谢谢。

【问题讨论】:

    标签: wolfram-mathematica


    【解决方案1】:

    也许您正在寻找RegionPlot

    RegionPlot[(-1 + x)^2 + (-1 + y)^2 < 1 && 
     x^2 + (-1 + y)^2 < 1 && (-1 + x)^2 + y^2 < 1 && x^2 + y^2 < 1, 
     {x, 0, 1}, {y, 0, 1}]
    

    【讨论】:

      【解决方案2】:

      请注意以下op_的使用(只有一个曲线和交点的方程组!):

      t[op_] :=Reduce[op[(x - #[[1]])^2 + (y - #[[2]])^2, 1], y] & /@ Tuples[{0, 1}, 2]
      tx = Texture[Binarize@RandomImage[NormalDistribution[1, .005], 1000 {1, 1}]];
      
      Show[{
      
        Plot[y /. ToRules /@ #, {x, 0, 1}, PlotRange -> {{0, 1}, {0, 1}}] &@ t[Equal], 
        RegionPlot[And @@ #, {x, 0, 1}, {y, 0, 1}, PlotStyle -> tx] &@ t[Less]}, 
      
      Frame->True,AspectRatio->1,FrameStyle->Directive[Blue, Thick],FrameTicks->None]
      

      【讨论】:

        【解决方案3】:

        如果出于任何特殊原因,您希望图片中出现虚线效果,您可以这样实现:

        pts = RandomReal[{0, 1}, {10000, 2}];
        pts = Select[pts,
          And @@ Table[Norm[# - p] < 1, {p,
           {{0, 0}, {1, 0}, {1, 1}, {0, 1}}}] &];
        Graphics[{Thick,
          Line[{{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}}],
          Circle[{0, 0}, 1, {0, Pi/2}],
          Circle[{1, 0}, 1, {Pi/2, Pi}],
          Circle[{1, 1}, 1, {Pi, 3 Pi/2}],
          Circle[{0, 1}, 1, {3 Pi/2, 2 Pi}],
          PointSize[Small], Point[pts]
        }]
        

        【讨论】:

        • 我想知道为什么有些点似乎“泄漏”:click here to see 可能是一些不正确的舍入或图形渲染的其他不精确。请注意,它们仅在左上角泄漏。
        • 原帖好像也有这个效果。当然,这些点确实具有正直径。使用 PointSize[Large] 的效果似乎更差,而使用 PointSize[Tiny] 的效果似乎更差。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-07-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多