In Mathematica 8.0.4 Rasterize[p]
uses the default styles even without ImageSize
:
$Version
SetOptions[EvaluationNotebook[],
StyleDefinitions ->
Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]],
Cell[StyleData["GraphicsLabel"], FontColor -> RGBColor[0, 1, 0], FontWeight -> Bold,
FontSize -> 16]}, StyleDefinitions -> "PrivateStylesheetFormatting.nb"]];
"8.0 for Microsoft Windows (64-bit) (October 7, 2011)"
p = Plot[x, {x, 0, 1}];
Rasterize[p]
Surprisingly, if we simply wrap Graphics
by Style
the Notebook's stylesheet is applied (wrapping by Pane
, Text
or Row
also work):
{Rasterize[Style[p]], Rasterize[Style[p], ImageSize -> 360]}
Unfortunately specifying the stylesheet via Style
doesn't work (checked with versions 8.0.4 and 11.0.1):
SetOptions[EvaluationNotebook[], StyleDefinitions -> Inherited]
Rasterize[Style[p,
StyleDefinitions ->
Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]],
Cell[StyleData["GraphicsLabel"], FontColor -> RGBColor[0, 1, 0], FontWeight -> Bold,
FontSize -> 16]}, StyleDefinitions -> "PrivateStylesheetFormatting.nb"]]]
But we can specify it as an option of Notebook
expression:
Rasterize[Notebook[{Cell[BoxData@ToBoxes@p, "Output"]},
StyleDefinitions ->
Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]],
Cell[StyleData["GraphicsLabel"], FontColor -> RGBColor[1, 0, 0], FontWeight -> Bold,
FontSize -> 16]}, StyleDefinitions -> "PrivateStylesheetFormatting.nb"]]]
Rasterize[p, RasterSize -> 200]~Image~{ImageSize -> 200}
$\endgroup$Show[p, ImageSize -> 200]
but in raster form. $\endgroup$Rasterize[Show[p, ImageSize -> 200]]
$\endgroup$