# Simplified way to save high-res plots in julia

**URL:** <https://discourse.julialang.org/t/simplified-way-to-save-high-res-plots-in-julia/95061>\
**Category:** Visualization\
**Tags:** plotting\
**Created:** [February 23, 2023, 5:57am UTC](https://discourse.julialang.org/t/simplified-way-to-save-high-res-plots-in-julia/95061 "2023-02-23T05:57:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaurya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shaurya/32/30468_2.png) [@shaurya](https://discourse.julialang.org/u/shaurya)\
**Post date:** [February 23, 2023, 5:57am UTC](https://discourse.julialang.org/t/simplified-way-to-save-high-res-plots-in-julia/95061/1 "2023-02-23T05:57:22Z")

</div>

I’m using jupyter notebooks and the julia plots look pretty decent in those notebook files. however, when I use `savefig` command, it saves it in a terrible resolution (almost indiscernible.)

One way of circumventing this is possibly using `size=(1200,800)` while plotting. However, this can often lead to cut-off or hidden y-labels or x-labels, or weirdly scaled plot. This essentially means coming back to the code and keep trying with different size numbers until you get the “perfect resolution.”

I’m not exactly sure where I’m wrong but I just want to know if there’s a simple way to save high-res images by default (nothing super HDish, but workable similar to say, default saved MATLAB plots)

Thanks!

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [February 23, 2023, 7:17am UTC](https://discourse.julialang.org/t/simplified-way-to-save-high-res-plots-in-julia/95061/2 "2023-02-23T07:17:25Z")

</div>

Use the `dpi` keyword argument. 400-600 dpi is usually good for prints.

```julia
julia> plot(randn(10), dpi=10)
Plot{Plots.GRBackend() n=1}

julia> savefig("/tmp/10.png")
"/tmp/10.png"

julia> plot(randn(10), dpi=1000)
Plot{Plots.GRBackend() n=1}

julia> savefig("/tmp/1000.png")
"/tmp/1000.png"

```

![10](https://global.discourse-cdn.com/julialang/original/3X/1/5/156b01716aa0039fb6dc992e62ae4778948d8f23.png)

 ![1000](https://global.discourse-cdn.com/julialang/original/3X/e/4/e49fd4ad19509b2cbafa303f138c664c2b0ab0ef.jpeg)

---

<div class="post-metadata">

**Author:** ![jmair](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmair/32/35117_2.png) [@jmair](https://discourse.julialang.org/u/jmair)\
**Post date:** [February 23, 2023, 10:12am UTC](https://discourse.julialang.org/t/simplified-way-to-save-high-res-plots-in-julia/95061/3 "2023-02-23T10:12:59Z")

</div>

Depending on your type of graph, it may be better to use `pdf` instead of `png`/`jpg` as it is a vector graphic. Vector graphics are of arbitrary quality and you can zoom in “infinitely” without any pixelation.

---

<div class="post-metadata">

**Author:** ![shaurya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shaurya/32/30468_2.png) [@shaurya](https://discourse.julialang.org/u/shaurya)\
**Post date:** [February 23, 2023, 5:21pm UTC](https://discourse.julialang.org/t/simplified-way-to-save-high-res-plots-in-julia/95061/4 "2023-02-23T17:21:21Z")

</div>

Thanks! This helps a lot! 😃

---

<div class="post-metadata">

**Author:** ![shaurya](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shaurya/32/30468_2.png) [@shaurya](https://discourse.julialang.org/u/shaurya)\
**Post date:** [February 23, 2023, 5:22pm UTC](https://discourse.julialang.org/t/simplified-way-to-save-high-res-plots-in-julia/95061/5 "2023-02-23T17:22:03Z")

</div>

That’s informative, although I’d still need it in png. Thanks for your reply! 🙂

---

<div class="post-metadata">

**Author:** ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)\
**Post date:** [February 23, 2023, 8:14pm UTC](https://discourse.julialang.org/t/simplified-way-to-save-high-res-plots-in-julia/95061/6 "2023-02-23T20:14:30Z")

</div>

svg is a vectors graphic format that may work as an alternative. Replace png with svg in your command and see if it works. It only works with some backends though.
