# Combine Plots into a single non-rasterized Graphic with no spacing [duplicate]

Suppose that I have two plots, pl1 and pl2:

pl1 = Plot[x, {x, 0, 1}, Frame -> True, ImageSize -> 350]
pl2 = Plot[x^2, {x, 0, 1}, Frame -> True, ImageSize -> 350]


I would like to (1) combine these plots side-by-side in a (2) non-rasterized graphic with (3) no spacing.

I get pretty close to my desired result by using Grid with Spacings -> 0:

Grid[{{pl1, pl2}}, Spacings -> 0]


The above satisfies my requirements (2) and (3): the result is non-rasterized, and there is no spacing between the plots. However, the above doesn't satisfy my requirement (1), that the plots be combined into a single Graphic object. That is, if I click on either of the plots, I see that they are separate Graphic objects:

So the above approach doesn't satisfy all of my requirements. (Why do I need the plots to be combined in a single Graphic? The reason is that I want to be able to place other Graphic objects -- e.g., text, arrows, shapes, etc. -- that span the two plots.)

Another possibility is to use ImageAssemble, but unfortunately this leads to a rasterized image:

ImageAssemble[{{pl1, pl2}}]


A third possibility is to use GraphicsGrid with Spacings -> 0:

GraphicsGrid[{{pl1, pl2}}, Spacings -> 0]


It seems that this produces a single Graphic object ((1)) that is not rasterized ((2)), but, unfortunately, there is spacing between the plots.

Do you have any suggestions? Is there any way to remove the spacing/padding in GraphicsGrid?

## marked as duplicate by Jens, Michael E2, m_goldberg, Dr. belisarius, C. E.Mar 12 '14 at 21:01

• @Jens Thanks. I think my question is more general, though. I just want to combine two Graphics objects side-by-side. It's almost like I am looking for a way to flatten a Grid objects so that two Graphics objects in neighboring cells are combined into a single Graphics object. – Andrew Mar 11 '14 at 21:11
• Why do you need the result to be a single Graphics object? What properties do single Graphics objects have that you need to rely on later? This is a very important question. You can combine them using Insets, but I'm not sure you'll like the result, as it might not behave the way you expect when you resize it. – Szabolcs Mar 11 '14 at 22:15
• Nowadays I use SciDraw for figures with multiple panels: mathematica.stackexchange.com/a/37880/12 But again, you can't resize a SciDraw figure directly. You have to decide on the size when you make it. – Szabolcs Mar 11 '14 at 22:16

You could do something like the following:

pl1=Plot[x,{x,0,1},Frame->True,ImageSize->350,

This removes the padding from the graphics themselves with the option ImagePadding, and a magic number of -0.07...There is likely a better way.
• Unfortunately, in this answer, the result is not a single Graphic object. Sorry. – Andrew Mar 11 '14 at 20:32