# How to reduce the spaces in the edges of the exported plot as optimal?

p1 = ComplexPlot3D[(z^2 + 1)/(z^2 - 1), {z, -2 - 2 I, 2 + 2 I},
PlotTheme -> "Detailed"]
Export["plot.png", p1]


When I export the plot, I have redundat spaces. How to reduce the spaces as optimal?

• Right click and using Trim Bounding Box  Oct 10, 2022 at 15:23
• Thanks. What is the code for Trim Bounding Box instead of right click? Because I will export the figure via command Export
– RF_1
Oct 10, 2022 at 15:41
• better to export to pdf and not png, as quality is better. You can import pdf as graphics to Latex. And For web browsing, you can always convert pdf images to svg using free tools, which is better than png. Oct 10, 2022 at 16:31
• In fact, I want to export it .as .eps or pdf for LaTeX. But Mathematica doesn't give good results in 3D plots to get vector format (such as .eps or .pdf) while 2D plots are good. (Or I can' t achieve)
– RF_1
Oct 10, 2022 at 16:37

I tried borrowing a technique from 21031:

p2 = ComplexPlot3D[(z^2 + 1)/(z^2 - 1), {z, -2 - 2 I, 2 + 2 I},
PlotTheme -> "Detailed", Method -> {"ShrinkWrap" -> True}]


but that didn't change much.

Then I tried:

p3 = ImageCrop[Rasterize[p2, ImageResolution -> 300]]
Export["C:/plot3.png", p3]


which looks ok.

Without Rasterizing

Using SphericalRegion->False:

p4 = ComplexPlot3D[(z^2 + 1)/(z^2 - 1), {z, -2 - 2 I, 2 + 2 I},
PlotTheme -> "Detailed", SphericalRegion -> False]

Export["C:/plot.png", p4]

• All right, is there a way without rasterizing the picture?
– RF_1
Oct 11, 2022 at 11:47
• I have updated the answer after trying many options. Hopefully this works for you.
– Syed
Oct 11, 2022 at 12:48
• In my case, Method -> {"ShrinkWrap" -> True} combined with ImagePadding -> None works well. Mar 20 at 15:56