Skip to main content

export - Exporting a rasterized Row of Graphics



I'm running some code based on @R.M.'s answer to this question to create a couple plots side by side.


I want to export the plots rasterized to a png. However, when I Rasterize the plot at a higher RasterSize or ImageResolution it splits the row on to two seperate lines. See the following simplified example below:


Rasterize[
With[{size = 250},
Row[Show[#, ImageSize -> {Automatic, size},
ImagePadding -> {{30, 15}, {40, 5}}] & /@ {Plot[
Sin[x], {x, -1, 1}], Plot[Sin[x], {x, -1, 1}]}]],
ImageResolution -> 200]

It looks like this:



Mathematica graphic


I want both plots on the same line but at higher resolution, like this:


Mathematica graphic


What is going wrong?



Answer



It is possible to give an explicit ImageSize to Row and if it is large enough to contain the graphics it will not wrap. If it is given in the form {maximum} it will be sized automatically. Infinity does not appear to work so I used 1*^6:


Rasterize[
With[{size = 250},
Row[Show[#, ImageSize -> {Automatic, size},
ImagePadding -> {{30, 15}, {40, 5}}] & /@ {Plot[

Sin[x], {x, -1, 1}], Plot[Sin[x], {x, -1, 1}]},
ImageSize -> {1*^6}]],
ImageResolution -> 200]

Comments