# Dpi parameter controlling size of plot display in Jupyter Notebook?

**URL:** https://discourse.julialang.org/t/dpi-parameter-controlling-size-of-plot-display-in-jupyter-notebook/61750
**Category:** Jupyter-Notebook
**Tags:** jupyter, plotting, plots, display
**Created:** [May 24, 2021, 10:39pm UTC](https://discourse.julialang.org/t/dpi-parameter-controlling-size-of-plot-display-in-jupyter-notebook/61750 "2021-05-24T22:39:18Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Michael\_Barmann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/michael_barmann/32/20389_2.png) [@Michael\_Barmann](https://discourse.julialang.org/u/Michael_Barmann)
#### Post date: [May 24, 2021, 10:39pm UTC](https://discourse.julialang.org/t/dpi-parameter-controlling-size-of-plot-display-in-jupyter-notebook/61750/1 "2021-05-24T22:39:18Z")

</div>

I’ve encountered some weird behavior when using Plots.jl. I’d like to know if this is a bug. Consider the following code:

```julia
using Plots; gr()
x = collect(0:0.1:50)
y = sin.(x)
plot(x,y, dpi = 50)

```

With `dpi = 50` the plot looks like this:

 ![dpi50](https://global.discourse-cdn.com/julialang/original/3X/f/0/f013912da5abd61e6648e968821f9abb70ac7c27.png)

Now setting `dpi = 100` drastically increases the size of the plot:

 ![dpi100](https://global.discourse-cdn.com/julialang/original/3X/6/2/62430e36b2acbfce0c38afea0eb25ec8b2f85af5.png)

And at `dpi = 200` the plot can’t even fit on the screen:

 ![dpi200](https://global.discourse-cdn.com/julialang/original/3X/8/5/851a4363f8effe6f4d861f5c748d12127a94da0d.png)

According to the documentation, dpi controls the “Dots Per Inch of output figures.” Indeed, when I use savefig(C:/Users/my/file/path), it’s clear that the dpi parameter does control the resolution of figures when they are saved. But why is it also controlling the size of the plot display in the notebook? I have tried to control the size using the `size()` parameter, but when dpi is specified `size()` seems to have no effect whatsoever on the plot size…

So is this a bug with Plots.jl? I’d really like to be able to adjust the plot resolution without changing the display size in the notebook.

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [May 27, 2021, 3:04pm UTC](https://discourse.julialang.org/t/dpi-parameter-controlling-size-of-plot-display-in-jupyter-notebook/61750/2 "2021-05-27T15:04:00Z")

</div>

Looking into the code and how this is passed on to the GR backend, we see that [`Plots.DPI` is hard coded to `100`](https://github.com/JuliaPlots/Plots.jl/blob/61f2d825b63a9e04eda52b374310a619fdb84f89/src/utils.jl#L918) and the [given DPI is then used to calculate a ratio](https://github.com/JuliaPlots/Plots.jl/blob/827462dc215128269e3fe520b14fe3aadabdc3a5/src/backends/gr.jl#L615).

This gets then passed to GR via `gr_setwsviewport`:  
[https://gr-framework.org/c-gr.html?highlight=setwsviewport#\_CPPv416gr\_setwsviewportdddd](https://gr-framework.org/c-gr.html?highlight=setwsviewport#_CPPv416gr_setwsviewportdddd)
