Function Repository Resource:

GraphicsInformation

Source Notebook

Get information about the rendered form of a Graphics object

Contributed by: Carl Woll

ResourceFunction["GraphicsInformation"][g]

returns sizing information about the graphics object g.

ResourceFunction["GraphicsInformation"][{g1,g2,}]

returns sizing information about the graphics objects g1,g2,.

Details and Options

ResourceFunction["GraphicsInformation"] returns sizing information for Graphics objects only.
Properties returned include:
"BasePlotRange"the unpadded plot range
"ImagePadding"the {{left,right},{bottom,top}} image padding
"ImagePaddingSize"the total {horizontal,vertical} image padding
"ImageSize"the actual image size
"PlotRange"the actual plot range
"PlotRangeSize"the actual size of the PlotRange portion of the graphic

Examples

Basic Examples (2) 

Generate a plot of Sin[x]:

In[1]:=
plot = Plot[Sin[x], {x, 0, 2 Pi}]
Out[1]=

Obtain information about the plot:

In[2]:=
ResourceFunction["GraphicsInformation"][Plot[Sin[x], {x, 0, 2 Pi}]]
Out[2]=

Scope (3) 

Generate several plots:

In[3]:=
plots = Table[Plot[f[x], {x, 0, Pi}], {f, {Sin, Cos, Tan}}]
Out[3]=

Obtain sizing information for each of the plots:

In[4]:=
ResourceFunction["GraphicsInformation"][plots]
Out[4]=

The total image padding used in each plot:

In[5]:=
Lookup[ResourceFunction["GraphicsInformation"][
  plots], "ImagePaddingSize"]
Out[5]=

Publisher

Carl Woll

Version History

  • 1.0.0 – 16 October 2019

Author Notes

The function uses the FrontEnd to get information about the graphic. For lists of graphics objects, it uses a single call to the FrontEnd instead of multiple calls for each graphic.

License Information