Message Boards Message Boards

0
|
5046 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Combine graphics with different PlotRange?

Posted 7 years ago

I would like to combine 2 graphics with different plotranges, but the plotranges for each graphic shoudnt change.

As an example:

Show[{
  Graphics[{Yellow, Rectangle[{-1, -1}, {1, 1}]}, 
   PlotRange -> {{-1, 1}, {-1, 1}}],
  Graphics[{Thick, Circle[{0, 0}, 0.9]}, PlotRange -> {{0, 1}, {0, 1}}]
  }]

What I need is this: enter image description here

What I get is this: enter image description here

I didnt found a simple solution for this. It would be great if someone could help me :)

POSTED BY: Juerg Baertsch
3 Replies

A PlotRange specification will not clip the graphics as you already found out. Unfortunately there is no 'clipping' primitive as of yet, though I have requested it. In this case you can solve it by using a 3rd argument in Circle. This will not work in general for any primitive unfortunately...

Graphics[{Yellow, Rectangle[{-1, -1}, {1, 1}], Black, Thick, 
  Circle[{0, 0}, 0.9, {0, Pi/2}]}, PlotRange -> {{-1, 1}, {-1, 1}}]

Sometimes you can get away by using Overlay, or rasterizing your Graphics and then using ImageOverlay. Or using RegionUnion and (discretised) versions of your primitives along with your a rectangular viewing range region. To sum up: you have to be creative sometimes!

POSTED BY: Sander Huisman
Posted 7 years ago

Thank you for the answer. I only thought there must be a solution, because PlotRangeClipping works fine, if there is some more space needed for axes and ticks:

enter image description hereenter image description here

But if there is no such solution, I try a workaround with hiding things with white Rectangles before drwaing on the "extra plotrange". I will also study your other suggetions.

Kind regards!

POSTED BY: Juerg Baertsch

You could also using Inset-ing a clipped (using PlotRangeClipping) graphics... I've never tried that...

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract