Message Boards Message Boards

0
|
4738 Views
|
8 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Clipping of graphs.

Dear All,

I have several graphs next to each other, in Mathematica it looks like this: enter image description here

However in the exported PDF it looks like this: enter image description here

Is there a way to get these clipping masks correct? I set PlotRangeClipping to True and I have set the correct PlotRange.

POSTED BY: Sander Huisman
8 Replies
Posted 10 years ago

Hi Sander, I think it's a bug, but it may be in the import rather than the export. When I look at the pdf with Acrobat it's much better.

SetDirectory[NotebookDirectory[]];

p1 = Graphics[{Pink, Disk[{0, 0}, 5]}, Frame -> True, PlotRange -> 4, 
  PlotRangeClipping -> True]

enter image description here

 Export["out.pdf", p1];

Import["out.pdf"]

enter image description here

But when I look at out.pdf with Acrobat or Photoshop I see this: (Converted to png for posting)

enter image description here

POSTED BY: David Keith

I'm not using the import feature, only the export. It should just be perfect, I don't see what is the problem. The positions (in pdf units) for the clipping ranges are known; the exact coordinates as for the frame!

I'd like to hear from someone from Wolfram...

EDIT: I think it just completely ignores the clipping masks in the Import.

POSTED BY: Sander Huisman
Posted 10 years ago

I see what you mean, Sander. Even in my example, the colored region of the pdf now laps over the top and bottom of the frame. Through the years, I have had a lot of problems getting pdf output that actually looked like the Mathematica graphic. Sometimes I have noticed that the results interact strongly with as-drawn and export image sizes.

Best, David

POSTED BY: David Keith

Generally it is fine, but clipping masks are always troublesome! They are somehow very difficult to handle. I made some complaints before but they never seem to fix them.

It would be very nice if there would be a clipping-mask primitive in one of the future versions, so you manually mask something!

--SH

POSTED BY: Sander Huisman
Posted 10 years ago

If this is a GraphicsGrid or GraphicsRow you might try Rasterize on it, then export the rasterized version.

POSTED BY: David Keith

Hi David,

It is not a GraphicsGrid/Row/Column. It is one Graphics object with several Inset objects because GraphicsGrid are very unreliable with styling, paddings et cetera. I can't have it rasterized though, I need the figure to be vector. Some parts of the figure are vectorised actually; the density maps are rasterized and placed back in to the figures using Prolog. This is merely done to save some on the file-size. Thanks for the suggestion though!

The problem though is way more general, even the simplest example goes wrong (in view and in export).

Graphics[{Pink, Disk[{0, 0}, 5]}, Frame -> True, PlotRange -> 4, PlotRangeClipping -> True]
Export["out.pdf", %]

Any more ideas? This seems like a bug, I'm open for spelunking and underground solutions creating clipping masks or hacks to fix this...

POSTED BY: Sander Huisman
Posted 10 years ago

I've often found exporting to eps works better, then you can convert that to pdf. Perhaps this will work for you.

POSTED BY: Greg Hurst

Hi Chip,

I tried that as well, to no avail. Same problem persists. Any idea if we can manually add a clipping mask with proper coordinates? Of course I can edit the output figure (eps/pdf) in illustrator. But this gets very tiresome with many figures.

Thanks for the suggestion though.

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