Message Boards Message Boards

3 Replies
1 Total Likes
View groups...
Share this post:

How to add a Region to Graphics?

Posted 9 years ago

I want to draw some graphics that also include a region. What i basically want to do is to do something along the lines

    Red, Disk[{0,0},1], 
    Blue, DiscretizeRegion[RegionDifference[Disk[{1,0},1], Disk[{1.5,0},0.75]]]

but the Graphics[] call complains 'An improperly formatted option was encountered while reading a Graphics. The option was not in the form of a rule.' I did my research, manual lookup and googled a lot, but found no understandable explanation how to unleash the power of Regions for my Graphics...

POSTED BY: Thomas Vogler
3 Replies

The only way I know to combine Graphics and Region is through Show

  RegionDifference[Disk[{1, 0}, 1], Disk[{1.5, 0}, 0.75]], 
 Graphics[{Red, Disk[{0, 0}, 1]}]]

I am under the impression that Graphics is an old functions aimed at display, while Region is a new concept, meant mainly for calculations. Different purposes and not neatly integrated.

POSTED BY: Gianluca Gorni

Try this:

RegionDifference[Disk[{1, 0}, 1], Disk[{1.5`, 0}, 0.75`]];
R = DiscretizeRegion[%];
Graphics[{LightBlue, MeshPrimitives[R, 2], Orange, Circle[{1, 0}, 1], 
  Blue, Circle[{1.5`, 0}, 0.75`]}]

enter image description here

The MeshPrimitives will convert Discretized Regions into Graphics primitives.

You can get a handy little palette I did for the Geometry routines here:

Geometry Palette

Posted 9 years ago

Hello Thomas, I tried the following that can help, but it seems that the Head Graphics and the head RĂ©gion are conflicting.

DiscretizeRegion[ RegionUnion[Disk[{0, 0}, 1], RegionDifference[Disk[{1, 0}, 1], Disk[{1.5, 0}, 0.75]]]]

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract