10
$\begingroup$

I like very much to wrap Mathematica images by Panel, which gives many of them a much better view. To be precise, if image is some illustration, plot etc. I would like to put it in Mathematica document as Panel@image Then I typically mark the output as Figure in the JournalArticle StyleSheet.

However, most of my documents should be later transformed into PDF for further use. This is unavoidable, since in my company nobody else uses Mathematica.

In the PDF document version the panel loses most of its attractiveness. The gray color becomes almost white, and the fine rim details (which made the panel looking in Mathematica like a 3D-relief) disappear. In this form Panel makes the view worse, rather than improve it. To be more precise, here is an image wrapped by a panel: please execute the following in Mathematica notebook:

Panel[Import["ExampleData/rose.gif"]]

Mathematica graphics

As you see the panel looks a 3D relief. It does not exist any more in the PDF version of the file that you can see below.

Besides, the panel color is much worse now.

Have you any idea of what could be done to improve the Panel view after the document is transformed into PDF?

$\endgroup$

2 Answers 2

13
$\begingroup$

You could mimic the panelled look by doing something like

panelBox[pt0 : {x0_, y0_}, 
  pt1 : {x1_, y1_}] := {{GrayLevel[.7], Rectangle[pt0, pt1]}, {White, 
   Polygon[{Offset[{.3, .3}, pt0], Offset[{2, 2}, pt0],
     Offset[{2, -2}, {x0, y1}], Offset[{-2, -2}, {x1, y1}], 
     Offset[{-.3, -.3}, {x1, y1}], Offset[{.3, -.3}, {x0, y1}]}]},
  {GrayLevel[.2], 
   Polygon[{Offset[{.3, .3}, pt0], Offset[{2, 2}, pt0],
     Offset[{-2, 2}, {x1, y0}], Offset[{-2, -2}, {x1, y1}], 
     Offset[{-.3, -.3}, {x1, y1}], Offset[{-.3, .3}, {x1, y0}]}]}}

panel[gr_] := Module[{dim},
  dim = Dimensions[Rasterize[gr][[1, 1]]][[{2, 1}]];
  Graphics[{panelBox[{-10, -10}, dim + 10], 
    Inset[gr, Center, Center, dim]}, ImageSize -> dim + 20]]

panel[Import["ExampleData/rose.gif"]]

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ Thank you, this is a nice approach. $\endgroup$ Commented May 2, 2012 at 10:31
9
$\begingroup$

It's not possible with any existing version of Mathematica. Mathematica uses drawing routines provided by the operating system to draw the Panel you prefer. In many cases it isn't possible to convert these OS-supplied appearances to a vector graphic suitable for inclusion in the PDF file, so Mathematica uses a generic appearance.

{#, Style[#, ControlsRendering -> "Generic"]}& @ Panel[Import["ExampleData/rose.gif"]]

Mathematica could, in theory, include a bitmap representation of the OS appearance, but that wouldn't zoom or print well.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.