# Ratio between the plot and the figure - white area around

**URL:** <https://discourse.julialang.org/t/ratio-between-the-plot-and-the-figure-white-area-around/97406>\
**Category:** Visualization\
**Tags:** plots\
**Created:** [April 12, 2023, 8:15pm UTC](https://discourse.julialang.org/t/ratio-between-the-plot-and-the-figure-white-area-around/97406 "2023-04-12T20:15:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gnicolosi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnicolosi/32/48031_2.png) [@gnicolosi](https://discourse.julialang.org/u/gnicolosi)\
**Post date:** [April 12, 2023, 8:15pm UTC](https://discourse.julialang.org/t/ratio-between-the-plot-and-the-figure-white-area-around/97406/1 "2023-04-12T20:15:16Z")

</div>

I am having trouble removing this white area around my plot:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/7/57183ee463c9b414648b4d9420e623d39a4fcec7.png)  
I have tried `aspect_ratio` and `size` options but couldn’t change. It happens both in VSCode and Jupyter notebook. It doesn’t happen in my laptop though. Any good insights? This same thing also doesn’t happen with 2D plots, only 3D…  
Thank you!

```julia
using Plots

# Generate some data for the plane
x = 0:0.1:1 # x-coordinates
y = 0:0.1:1 # y-coordinates
z = [-i -j +1 for i in x, j in y]

plot(x, y, z, 
      st=:surface,      
      color=:lightgray, 
      alpha=0.3,        
      legend=false,
      xlims=(0.2,0.5),
      ylims=(0.2,0.5),
      zlims=(0.2,0.5),
      camera=(80,20),
      xticks=0.2:0.1:0.5,
      yticks=0.2:0.1:0.5,
      zticks=0.25:0.1:0.55,
      dpi=:400)

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [April 12, 2023, 11:23pm UTC](https://discourse.julialang.org/t/ratio-between-the-plot-and-the-figure-white-area-around/97406/2 "2023-04-12T23:23:34Z")

</div>

Plots.jl is more an art than a science…

The best I could get was using both `size` and `Measures` with a `-10mm` margin, more than that had no effect:

 ![Plots_gr_3D_margins](https://global.discourse-cdn.com/julialang/original/3X/2/9/292fe9a3d650da2a8ad555170cc4a060ce2a2579.png)

> **CODE**
>
> ```julia
> using Measures, Plots; gr(size=(600,600))
> 
> # Generate some data for the plane
> x = 0:0.1:1 # x-coordinates
> y = 0:0.1:1 # y-coordinates
> z = [(-i -j +1) for i in x, j in y]
> 
> plot(x, y, z, 
> st=:surface,      
> color=:lightgray, 
> alpha=0.3,        
> legend=false,
> xlims=(0.2,0.5),
> ylims=(0.2,0.5),
> zlims=(0.2,0.5),
> camera=(80,20),
> xticks=0.2:0.1:0.5,
> yticks=0.2:0.1:0.5,
> zticks=0.25:0.1:0.55,
> dpi=:400,
> margins=-10mm
> )
> 
> ```

---

<div class="post-metadata">

**Author:** ![gnicolosi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnicolosi/32/48031_2.png) [@gnicolosi](https://discourse.julialang.org/u/gnicolosi)\
**Post date:** [April 13, 2023, 2:41pm UTC](https://discourse.julialang.org/t/ratio-between-the-plot-and-the-figure-white-area-around/97406/3 "2023-04-13T14:41:32Z")

</div>

This solves my problem for now, but there’s definitely something mysterious with the formatting in newer versions of `Plots.jl` perhaps. For instance, I was always able to create surface plots like this immediately both in VSCode and Jupyter. Somehow it adjusted nicely to the screen:

 ![MN2_2D_vel2dot2_toy_control_pp3](https://global.discourse-cdn.com/julialang/original/3X/1/6/16ec7970372647ca0996d3ac7ce6166288212b30.jpeg)  
Now, the default has become something like this, which is way worse looking and impossible to make it match the one above:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/5/f5d12902cc77002d7e8b570a4b1d29346111281e.png)  
Do you think I messed up some backend thing (?) with another package or something alike?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [April 13, 2023, 4:15pm UTC](https://discourse.julialang.org/t/ratio-between-the-plot-and-the-figure-white-area-around/97406/4 "2023-04-13T16:15:02Z")

</div>

What about a MWE?

---

<div class="post-metadata">

**Author:** ![gnicolosi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gnicolosi/32/48031_2.png) [@gnicolosi](https://discourse.julialang.org/u/gnicolosi)\
**Post date:** [April 14, 2023, 4:32pm UTC](https://discourse.julialang.org/t/ratio-between-the-plot-and-the-figure-white-area-around/97406/5 "2023-04-14T16:32:44Z")

</div>

I just marked your other answer as the solution. I think I couldn’t explain well my problem, but basically the same plot is printed differently depending on the version of Plots. It used to be neat in the past, now it is no longer and I can’t make it go back to its original style. Thank you anyways!
