Wolfram Research

Function Repository Resource:

GraphicsInformation

Source Notebook

Return information about the rendered form of a Graphics object, such as the image padding size and the actual plot range used

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

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

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

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]=

Resource History

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