Mathematica is a great tool but when it comes to layout generation is quite poorly intuitive: I would love that exporting to images and SVGs could be more friendly and compliant with graphic design mindset.

I created a graph object and labeled a vertex with a chart, and want to automate composed layouts.

I know Graphics object is not an Image object and a Graph object is not automatically converted to a Graphics object. I used Show command for the purpose.

However cannot figure out how to scale the final composition so as to have the exact measures in pixels and resolution, as it would be in photoshop or other computer graphics software.

Let's take this Column object that represent a composed layout.

v1 = Column[{
   Text[Style[sector[i], FontSize -> 22]],
   Show[sgSectorProfessions[i], ImageSize -> 300],   (* here I convert a Graph Object into a Graphics and set the image size, I thought 300 px but it is not *)
    Values[KeyTake[labelsColors, getPowers[i]]], getPowers[i],
    LegendLayout -> "Row"
  , ItemSize -> {Automatic, {1, 3} , Automatic} (* here tried to tell proportions of cells in the columns, but no effect  *)
  , Dividers -> Center];

And now I try to export it:

Export["v1_sector_" <> ToString[i] <> ".png", v1, 
 ImageResolution -> 300, ImageResize -> {300, 300}] (* here I try to get 300 x 300 px image, or Automatic x 300px would also be ok, but not working  *)

In SVG, it keeps the proportions. In png, layout is not consistent and the proportions look different; also, the size of the automated images have all slightly different dimensions: e.g. 1250 x 1004, 1266 x 1502, etc.

Instead, I would have expected / would like to have all images to have these sizes: column width : Automatic column height : 300px image resolution: 300dpi (or 72dpi but with crispy fonts and edges)

What am I missing to produce a consistent layout in automated data-visualizations, possibly similar to scripts for Photoshop / Illustrator ?

  • 3
    $\begingroup$ You should give a minimal example that everybody can test. $\endgroup$
    – SquareOne
    Commented Jun 9, 2022 at 8:25


Your Answer

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