1
$\begingroup$

Here is the code that I have:

a = Disk[{0, 1}, 0.7];
b = Disk[{-0.5, 0}, 1.3];
c = Disk[{0.5, 0}];

subsets = Subsets[{a, b, c}, {1, 3}];

subsetscolors = Map[
   Function[
    {c},
    Blend[
     Flatten[
      Map[
       Table[
         Map[
          Append[#, 1.5/Length[c]] &,
          c
          ], 2
         ] &,
       c
       ]
      ]
     ]
    ],
   Subsets[{RGBColor["#f839ff"], RGBColor["#fff839"], 
     RGBColor["#40ff39"]}, {1, 4}]
   ];

RegionPlot[
 Evaluate[
  DiscretizeRegion[RegionDifference[
      BooleanRegion[And, #],
      BooleanRegion[Or, 
       Complement[{a, b, c, EmptyRegion[2]}, #]]]] & /@ subsets
  ],
 PlotLabels -> Callout[
   (Apply[
     StringJoin, {{"a"}, {"b"}, {"c"}, {"d"}, {"e"}, {"f"}, {"g"}}, \
{1}]),
   Center
   ],
 Sequence[
  PlotStyle -> subsetscolors,
  BoundaryStyle -> Directive[Thickness[0.01], Black],
  Frame -> True,
  LabelStyle -> {20},
  PerformanceGoal -> "Quality",
  ImageSize -> 400
  ]
 ]

Producing this output:

enter image description here

Because I vary the radii, not all of the circles are being drawn in full.

Sometimes (but I have been unable to reproduce this for StackExchange) varying the radii for the three disks will change the areas where the disks are not fully rendered.

I am guessing my issue is with the maybe to do with PerformanceGoal ->, but as I have this set to "Quality" I do not know what the problem is.

$\endgroup$

3 Answers 3

3
$\begingroup$

I refer to this similar post to solve your problem(just use the plotrange as bounding box via the second argument of DiscretizeRegion).

a = Disk[{0, 1}, 0.7];
b = Disk[{-0.5, 0}, 1.3];
c = Disk[{0.5, 0}];

subsets = Subsets[{a, b, c}, {1, 3}];

subsetscolors = 
  Map[Function[{c}, 
    Blend[Flatten[
      Map[Table[Map[Append[#, 1.5/Length[c]] &, c], 2] &, c]]]], 
   Subsets[{RGBColor["#f839ff"], RGBColor["#fff839"], 
     RGBColor["#40ff39"]}, {1, 4}]];

RegionPlot[
 Evaluate[DiscretizeRegion[
     RegionDifference[BooleanRegion[And, #], 
      BooleanRegion[Or, 
       Complement[{a, b, c, EmptyRegion[2]}, #]]], {{-2, 2}, {-2, 
       2}}] & /@ subsets], 
 PlotLabels -> 
  Callout[(Apply[
     StringJoin, {{"a"}, {"b"}, {"c"}, {"d"}, {"e"}, {"f"}, {"g"}}, \
{1}]), Center], 
 Sequence[PlotStyle -> subsetscolors, 
  BoundaryStyle -> Directive[Thickness[0.01], Black], Frame -> True, 
  LabelStyle -> {20}, PerformanceGoal -> "Quality", ImageSize -> 400],
  PlotRange -> Full]

enter image description here

It should be noted that the editor does not allow us to manually adjust the display size of the image, which is too inconvenient.

$\endgroup$
4
$\begingroup$

It's just a simple test.

{p, q, r} = {x^2 + (y - 1)^2 - 0.7^2 > 0, (x + 0.5)^2 + y^2 - 1.3^2 > 
    0, (x - 0.5)^2 + y^2 - 1^2 > 0};
boolean = 
  Reverse[List @@ 
    Distribute[And[Or[p, ! p], Or[q, ! q], Or[r, ! r]], Or, And]];
RegionPlot[boolean, {x, -2, 2}, {y, -2, 2}, 
 PlotLabels -> Placed[{"a", "b", "c", "d", "e", "f", "g"}, Center], 
 PlotStyle -> {Red, Orange, Yellow, Green, Blue, Cyan, Purple, Brown},
  PlotPoints -> 30, Frame -> False] 

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ This one looks better than mine by far, but I need simplicity. But thanks! I will be able to use this in the future when making less formal documents. $\endgroup$
    – Robjobbob
    Commented Aug 9, 2020 at 15:23
0
$\begingroup$

Are the radius values important? This works for me:

a = Disk[{0, 1}, 0.5];
b = Disk[{-0.5, 0}];
c = Disk[{0.5, 0}];

Moving the centers by 0.1 also works:

a = Disk[{0, 1}, 0.7];
b = Disk[{-0.4, 0}, 1.3];
c = Disk[{0.6, 0}];
$\endgroup$
2
  • $\begingroup$ Yes, changing two radii are important. So this does not work sorry. $\endgroup$
    – Robjobbob
    Commented Aug 5, 2020 at 4:03
  • $\begingroup$ How about moving the centers just a little bit? :) $\endgroup$
    – Rodrigo
    Commented Aug 5, 2020 at 4:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.