# Setting size (resolution) of makie plot when plotting?

**URL:** <https://discourse.julialang.org/t/setting-size-resolution-of-makie-plot-when-plotting/91148>\
**Category:** Visualization\
**Created:** [December 2, 2022, 3:04pm UTC](https://discourse.julialang.org/t/setting-size-resolution-of-makie-plot-when-plotting/91148 "2022-12-02T15:04:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [December 2, 2022, 3:04pm UTC](https://discourse.julialang.org/t/setting-size-resolution-of-makie-plot-when-plotting/91148/1 "2022-12-02T15:04:44Z")

</div>

I want to change the size of a plot I am making in Makie. I try:

```julia
graphplot(mygraph,resolution=(500,500))

```

but get an error:

```julia
ERROR: setting resolution for scene via plot attribute not supported anymore

```

Is there some other command to use to change the plot’s size instead of resolution?

---

<div class="post-metadata">

**Author:** ![fatteneder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatteneder/32/33991_2.png) [@fatteneder](https://discourse.julialang.org/u/fatteneder)\
**Post date:** [December 2, 2022, 4:02pm UTC](https://discourse.julialang.org/t/setting-size-resolution-of-makie-plot-when-plotting/91148/2 "2022-12-02T16:02:53Z")

</div>

If it is just one plot element in a figure then increasing the resolution increases the plot’s size, e.g. you can use

```julia
using CairoMakie
CairoMakie.activate!()

f = Figure(resolution=(500,500))
ax = Axis(f[1,1])
lines!(ax, 1:5, 1:5)

save("mwe.png", f)

```

If you want to create a figure with multiple plot elements, where the figure’s space is not equally partitioned between the plots, then you will have to dive into `GridLayout`s. Here is a link to a tutorial for this: [Layout Tutorial](https://docs.makie.org/stable/tutorials/layout-tutorial/)

---

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [December 2, 2022, 4:19pm UTC](https://discourse.julialang.org/t/setting-size-resolution-of-makie-plot-when-plotting/91148/3 "2022-12-02T16:19:06Z")

</div>

> [@Torkel](#):
>
> `graphplot(mygraph,resolution=(500,500))`

Sorry, I do not really understand. So I have only used plots where I would do `plot(..., size=(400,400))`. However, there is no similar approach in Makie?

---

<div class="post-metadata">

**Author:** ![fatteneder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatteneder/32/33991_2.png) [@fatteneder](https://discourse.julialang.org/u/fatteneder)\
**Post date:** [December 2, 2022, 4:29pm UTC](https://discourse.julialang.org/t/setting-size-resolution-of-makie-plot-when-plotting/91148/4 "2022-12-02T16:29:40Z")

</div>

Sorry, but I am not so familiar with `Plots.jl`.

When I try running a MWE from the `Plots` docs, e.g. this one [Introduction · Plots](https://docs.juliaplots.org/stable/GraphRecipes/introduction/), and I add `resolution=(500,500)` in, I don’t see anything changing.

Could you maybe provide an example figure to illustrate of what is not working and/or what you want to achieve?

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [December 2, 2022, 8:57pm UTC](https://discourse.julialang.org/t/setting-size-resolution-of-makie-plot-when-plotting/91148/5 "2022-12-02T20:57:47Z")

</div>

Makie figures can contain multiple plots, and resolution is set at the figure level rather than the plot level. Plotting with the simplified interface `plot(...)` implicitly creates a figure container to plot into, but you can set the resolution of that figure (as well as other figure or axis attributes) with the `figure` (and `axis`) keyword arguments. This should work: `graphplot(mygraph; figure=(resolution=(500,500),))`

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [December 2, 2022, 9:16pm UTC](https://discourse.julialang.org/t/setting-size-resolution-of-makie-plot-when-plotting/91148/6 "2022-12-02T21:16:33Z")

</div>

The differences between Plots.jl and Makie.jl can sometimes be a bit confusing, especially because both use a function called `plot`. But Plots’s `plot` creates abstract objects which are descriptions of figures with possibly multiple subplots arranged in layouts. When you `plot!` into those, you just add to the description, which is at the end converted into a complete visualization in whatever backend you have activated.

In Makie, there’s `Figure` (a `Scene` with a `GridLayout`), which can contain stuff like `Axis`, `Colorbar`, `Legend`, etc, and all of these objects are built up out of `Scenes` which contain “plot primitives” such as `Lines`, `Scatter`, `Heatmap`, etc. All plotting functions at their core create such “plot primitives”, but, as a convenience, the containers for these are created as well in the default case. Usually, that’s a `Figure` with an `Axis` inside. So `heatmap(...)` makes a `Heatmap` plot object, which is stored inside an `Axis`, which is placed inside a `Figure`. To pass keyword arguments to the `Axis`, you can do `heatmap(...; axis = (; title = ...` and for the `Figure` you do `heatmap(...; figure = (; resolution = ...`.

Remember that in Plots.jl, you don’t control all these different objects, you just make an abstract “plot description”, therefore all keywords are top-level keywords, and Plots.jl sorts out which relate to what would be the `Figure` in Makie, or the `Axis`, or the `Plot`. But in Makie, it’s completely separated, that’s why all `Figure` keywords have to be sent in via the special `figure` keyword. For example, in principle some plot might have a `title` attribute, and this way you could set that plus the axis title via `some_plot(...; title = "Plot title", axis = (; title = "Axis title"...`.

If, in Makie, you go the mutation route, the plotting function loses its ability to pass `Figure` and `Axis` information on, because those have already been created beforehand:

```julia
f = Figure(resolution = ...)
ax = Axis(f[1, 1], title = ...)
heatmap!(ax, ...; # no figure or axis keyword allowed here, those already exist

```

---

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [December 5, 2022, 3:24pm UTC](https://discourse.julialang.org/t/setting-size-resolution-of-makie-plot-when-plotting/91148/7 "2022-12-05T15:24:50Z")

</div>

Thanks for the throughout explanation of what was going on, that was really useful!.
