For example, I have a grid of plot stored in variable plots
plots = Grid[{{Grid[
Table[ListDensityPlot[{{1, 1, 1, 1}, {1, 2, 1, 2}, {1, 1, 3,
1}, {1, 2, 1, 4}}, Mesh -> All], {i, 2}, {j, 2}]],
Plot[x, {x, 0, 1}, PlotLabel -> "yyy"]}}]
and it is looked like in frontend
If I export it to jpg like
Export["test.jpg", plots]
The image looking is exactly the same as it shows in mathematica frontend. However, the resolution is low.
But I want high resolution, however,
Export["test.jpg", plots, ImageResolution -> 600]
gives
So my questions is
- why
ImageResolution
affect the looking? - how to export
plots
as high resolution jpg, while keep the same visual looking in frontend?
update
I found even Jens' trick will fail for some complicated grid of graphics. For example, try below
plot = Plot[x, {x, 0, 1}, Frame -> True, AspectRatio -> 1];
plots = Grid[{{Grid[Table[plot, {i, 2}, {j, 2}]],
Plot[x, {x, 0, 1}, PlotLabel -> "yyy"]}}];
newplots =
Grid[{{Show[plot, ImageSize -> 200, AspectRatio -> 2], plots}}]
and Jens' method
h = First@ImportString[ExportString[newplots, "PDF"]];
Rasterize[h, ImageResolution -> 300]
You will notice significant difference.
After tested many solutions, I found the most stable way to "export" to file and keep exactly the same looking as in front end and keep high resolution is using "save sections as" PDF for the whole cell. You can confirm that this is not equivalent to Export["..pdf",...]
using newplots
as test. Though an undesirable thing is that the output file will have cell tag.
However, this operation can not batch processing, if we want to save a bunches of files.
So I am wondering, Mathematica do have a mechanism which can keep all the same looking when saving cell, no matter how complicated the graphics is ( grid, even grid of grid). There must be a underlining command that can mimic "save section as" PDF. Does anyone know the command to mimic "save section as" PDF, so we can do batch processing?
ImageSize
:img = Import@Export["test.png", plots, ImageSize -> 1200, ImageResolution -> 200 ];
$\endgroup$ImageSize
, ifImageResolution
is 600, the image is still wrong. Then why200
? It seems rather arbitary $\endgroup$