# Set absolute size of Axis or frame for a plot

I have to publish some work and it requires to meet specific criteria for the image size and plot size. 1) the Area of the figure must be fix 2) the width of the x-axis also must be fix for any plot inside the figure. As a mere example let's consider the following plot

Plot[x, {x, 0, 3}, Axes -> False, Frame -> True, AspectRatio -> 1,
ImageMargins -> {{0, 130}, {0, 172}}, ImageSize -> {414, 370}]


In this case the total Figure size once exported is equal to ImageSize plus the ImageMargins values. But I don't have any control on the resulting size of the x-Axis in the plot.

What I want to control is the X-axis size (in dpi preferable) of the plot and let mathematica calculate the padding necessary in each side regardless of any other object in the Figure like the labels or title.

• ImagePadding and ImageSize (and AspectRatio) are what you need to adjust and remove ImageMargins Feb 19, 2018 at 5:30

You can use the syntax ImageSize->Automatic->size to set the plot range to a specified size. For your example:

plot = Plot[
x,
{x, 0, 3},
Frame -> True,
ImageSize -> Automatic -> 400
]


You can use my GraphicsInformation function to verify the plot range size. Install with:

PacletInstall[
"GraphicsInformation",
"Site" -> "http://raw.githubusercontent.com/carlwoll/GraphicsInformation/master"
];


<<GraphicsInformation


Now, let's check:

"PlotRangeSize" /. GraphicsInformation[plot]


{400., 247.214}

• This function gives me the values in pt , but I want to set that value Feb 20, 2018 at 1:21
• @JaredLo To set the value, just use ImageSize->Automatic->size, as I said in my answer. The function GraphicsInformation` was just used to show you that my answer does what I claim it does. Feb 20, 2018 at 1:25
• after try "plot = Plot[x, {x, 0, 3}, Frame -> True, ImageSize -> Automatic -> 400] " and "PlotRangeSize" /. GraphicsInformation[plot] I got a completely different value {600., 370.82}. I'm using mathematica 11.1 Feb 20, 2018 at 2:31
• @JaredLo That's very strange. Does the plot look like it's 400 pixels or 600 pixels? Are you changing the Magnification at all? Feb 20, 2018 at 2:42