1
$\begingroup$

Given a simple graphics object like a disc in black:

Graphics[Disk[]]

Is it possible to split the disc in the middle, i.e. color each half differently e.g. left half in black and right half in red?

$\endgroup$
  • 2
    $\begingroup$ See the three-argument form of Disk in the documentation. Alternatively, construct it from Polygons (see CirclePoints). $\endgroup$ – Szabolcs Apr 11 '17 at 11:30
  • 2
    $\begingroup$ Also DiskSegment. $\endgroup$ – swish Apr 11 '17 at 11:46
7
$\begingroup$
Graphics[{
  Black, DiskSegment[{0, 0}, 1, {Pi/2, 3 Pi/2}],
  Red, DiskSegment[{0, 0}, 1, {3 Pi/2, 5 Pi/2}]
  }]

disk

EDIT: DiskSegment was introduced in MMA 10.2. Alternative code that works in previous versions is simply...

Graphics[{
  Black, Disk[{0, 0}, 1, {Pi/2, 3 Pi/2}],
  Red, Disk[{0, 0}, 1, {3 Pi/2, 5 Pi/2}]
  }]
$\endgroup$
  • $\begingroup$ Thank you! But it seems, that the DiskSegment function doesn't exist in mathematica 10.1? Which version are u using? $\endgroup$ – holistic Apr 11 '17 at 12:25
  • $\begingroup$ @holistic Please see my edited answer. I have just learned about this use of Disk. $\endgroup$ – Pinti Apr 11 '17 at 12:36
  • $\begingroup$ Great, thank you!! $\endgroup$ – holistic Apr 11 '17 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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