如何在Mathematica中给绘图着色

4
我想生成像下面这样的图形。

enter image description here

虽然我可以完成框架,但我不知道如何生成阴影。我想知道在Mathematica中给图形染色的一般方法。请帮忙。谢谢。
3个回答

8
也许你正在寻找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}]

Mathematica graphics


7
请注意以下内容中使用了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]

enter image description here


5

如果出于某种特殊原因,您希望在图片中实现点状效果,可以按照以下方法实现:

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

Mathematica graphics


1
我想知道为什么有些点似乎在“泄漏”:点击此处查看 可能是由于图形渲染中的不正确舍入或其他不精确性导致的。请注意,它们只在左上角泄漏。 - Szabolcs
1
原帖似乎也有这种效果。当然,这些点确实具有正直径。使用PointSize [Large]时,效果似乎更糟,而使用PointSize [Tiny]则不太糟。 - Mark McClure

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接