Assembling multiple Graphics objects
Consider the following simple example:
f[x_] = Sin[5 x] + Sin[3 x];
p1 = PolarPlot[f[x], {x, 0, 2 Pi}, ImageSize -> 50 {5, 2.5},
Frame -> True]
p2 = PolarPlot[f'[x], {x, 0, 2 Pi}, ImageSize -> 50 {5, 3},
Frame -> True]
which produces the following two figures
Now I'd like to align the two of them, one on top of each other, without any additional gaps. Doing FullGraphics@GraphicsColumn[{p1, p2}, Frame -> All]
, returns an object with additional white space around the shorter figure (I've turned the frames on in all the objects to illustrate this)
I couldn't find a way to force each of the column "cells" to fit vertically to the image size (NOTE: I'm aware that in my example, there's additional horizontal whitespace in the second figure, and that is intentional. I'm only trying to fit it snugly vertically). I tried playing around with the Spacings
option, but that's still not satisfactory. So, my first question would be: "Is there a way I can do this using GraphicsGrid
or GraphicsColumn
or by any other means?"
Another way would be to use ImageAssemble
like so:
ImageAssemble[Map[FullGraphics, {{p1}, {p2}}, {2}]]
which does what I want, but gives a rasterized image (the following is a screen grab, as the saved file had much poorer resolution).
My actual figures are neat vector plots and I d开发者_StackOverflow社区on't even want to think about rasterizing them, no matter how high the resolution. So, my second question would be: "Is there a way to get a vector graphics output from ImageAssemble
?" If it helps, I'm using Mma7
and saving my graphics as Export["filename.pdf",expr]
.
I know that this is possible using LevelScheme
for the example shown. However, not all plotting functions are compatible with LevelScheme
and will not work in all cases.
Does the result have to be a graphic? If not you can just use a regular column:
Column[{p1, p2}, Spacings -> 0]
Building on Brett's answer, this might be what you want:
FullGraphics@GraphicsGrid[{{p1}, {p2}}, Spacings -> 0]
Method 1:
- Use
ImageAssemble[{image1},{image2}....]
. Can use
ImagePad
to add some space around each image:ImageAssemble[ {ImagePad[image1,m1]}, {ImagePad[image2,m2]},...]
Note - all images must be of same size (Use
ImageDimensions
, and appropriate choice ofm1
,m2
...).
Method 2:
define an array of images of dimension rows x cols, say "myphotos"
ImageAssemble[myphotos]
精彩评论