# Julia Plots savefig whitespace issue

**URL:** <https://discourse.julialang.org/t/julia-plots-savefig-whitespace-issue/54081>\
**Category:** Visualization\
**Created:** [January 27, 2021, 8:54pm UTC](https://discourse.julialang.org/t/julia-plots-savefig-whitespace-issue/54081 "2021-01-27T20:54:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gideonsimpson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gideonsimpson/32/1928_2.png) [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Post date:** [January 27, 2021, 8:54pm UTC](https://discourse.julialang.org/t/julia-plots-savefig-whitespace-issue/54081/1 "2021-01-27T20:54:01Z")

</div>

When saving figures generated by `Plots.jl` with the `pyplot`, is there a straightforward way to trim the extra whitespace when I call `savefig`?

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [January 27, 2021, 9:52pm UTC](https://discourse.julialang.org/t/julia-plots-savefig-whitespace-issue/54081/2 "2021-01-27T21:52:37Z")

</div>

I do not know if there is a pure Julia solution, but you can crop the image with the `convert` command in linux using:

```julia
julia> run(`convert -trim in.png out.png`)

```

(input and output may have the same name as well).

---

<div class="post-metadata">

**Author:** ![gideonsimpson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gideonsimpson/32/1928_2.png) [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Post date:** [January 28, 2021, 3:12am UTC](https://discourse.julialang.org/t/julia-plots-savefig-whitespace-issue/54081/3 "2021-01-28T03:12:52Z")

</div>

What if I’m working with PDF instead of PNG?

---

<div class="post-metadata">

**Author:** ![gideonsimpson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gideonsimpson/32/1928_2.png) [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Post date:** [January 28, 2021, 3:21am UTC](https://discourse.julialang.org/t/julia-plots-savefig-whitespace-issue/54081/4 "2021-01-28T03:21:57Z")

</div>

Got it to work with the `pdfcrop` command line tool. Still, it would be nice if there were a way to get `Plots.jl` to tighten up figures.
