Simplified way to save high-res plots in julia

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)


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

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

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

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

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



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.


Thanks! This helps a lot! :smiley:

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

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.

1 Like