# How to customize figure size (and other things) with using GraphMakie?

**URL:** <https://discourse.julialang.org/t/how-to-customize-figure-size-and-other-things-with-using-graphmakie/122572>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [November 13, 2024, 4:51am UTC](https://discourse.julialang.org/t/how-to-customize-figure-size-and-other-things-with-using-graphmakie/122572 "2024-11-13T04:51:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xing\_Shi\_Cai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xing_shi_cai/32/14128_2.png) [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Post date:** [November 13, 2024, 4:51am UTC](https://discourse.julialang.org/t/how-to-customize-figure-size-and-other-things-with-using-graphmakie/122572/1 "2024-11-13T04:51:33Z")

</div>

I have the following code to draw a directed graph with edge weights.

```julia
## Load the packages
using Random
using CairoMakie
using GraphMakie
using Graphs
using LaTeXStrings
using Colors

## Create a random directed graph
vnum = 4
enum = 6
ilabels = string.('a':'z')[1:vnum]
seed = 1234
g = erdos_renyi(4, 6, is_directed = true, seed = seed)
Random.seed!(seed)
elabels = LaTeXString.(string.(rand(1:10, enum)))

## Plot the data
font_size = 32
fig, ax, p = graphplot(
    g;
    ilabels = ilabels,
    ilabels_fontsize = font_size,
    elabels = elabels,
    elabels_fontsize = font_size,
    node_color = :orange,
    edge_color = :gray,
    edge_width = 4,
    node_strokewidth = 4,
    arrow_shift = :end,
    arrow_size = 40,
);
hidedecorations!(ax);
hidespines!(ax);
colsize!(fig.layout, 1, Aspect(1, 1.0));
resize_to_layout!(fig);
fig

```

My question is how can I change the figure size? I have tried to add `size` parameter to `graphplot` without success.

Also, as you can see, the nodes in the picture gets cut off when they are too large. Is there any way to avoid this?

 ![display](https://global.discourse-cdn.com/julialang/original/3X/b/c/bca432691e2ca2f0e1b0afa36b005d14645258b7.png)

Thank you!

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [November 13, 2024, 6:29am UTC](https://discourse.julialang.org/t/how-to-customize-figure-size-and-other-things-with-using-graphmakie/122572/2 "2024-11-13T06:29:03Z")

</div>

If `graphplot` behaves similar to other Makie plotting function, then you need to do

```julia
fig, ax, p = graphplot(
    g;
    figure = (; size=(200,200),
    # other kwargs
)

```

to “pass” the `size` kwarg through to the underlying `Figure`.

---

<div class="post-metadata">

**Author:** ![Xing\_Shi\_Cai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xing_shi_cai/32/14128_2.png) [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Post date:** [November 13, 2024, 7:29am UTC](https://discourse.julialang.org/t/how-to-customize-figure-size-and-other-things-with-using-graphmakie/122572/3 "2024-11-13T07:29:59Z")

</div>

This works! 😃

Any idea how I may extend the cut off position a bit?

---

<div class="post-metadata">

**Author:** ![Xing\_Shi\_Cai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xing_shi_cai/32/14128_2.png) [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Post date:** [November 19, 2024, 1:53am UTC](https://discourse.julialang.org/t/how-to-customize-figure-size-and-other-things-with-using-graphmakie/122572/4 "2024-11-19T01:53:33Z")

</div>

After posting on Github, I got a reply: [Nodes get cut-off when ilabels\_fontsize is set to large number. · Issue #196 · MakieOrg/GraphMakie.jl · GitHub](https://github.com/MakieOrg/GraphMakie.jl/issues/196#issuecomment-2483807842)

---

<div class="post-metadata">

**Author:** ![hexaeder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hexaeder/32/24403_2.png) [@hexaeder](https://discourse.julialang.org/u/hexaeder)\
**Post date:** [November 19, 2024, 4:56am UTC](https://discourse.julialang.org/t/how-to-customize-figure-size-and-other-things-with-using-graphmakie/122572/5 "2024-11-19T04:56:14Z")

</div>

Have you had success using the linked workaround in discourse or the [solution by mschauer](https://github.com/MakieOrg/GraphMakie.jl/issues/141#issuecomment-1759077321)?  
If your image is fairly static and it is acceptable to find suitable limits by hand, you can use the `Axis=(; limits…)` keyword of the plot function to set manual exits limits from within a single plot command.

---

<div class="post-metadata">

**Author:** ![Xing\_Shi\_Cai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xing_shi_cai/32/14128_2.png) [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Post date:** [November 19, 2024, 6:59am UTC](https://discourse.julialang.org/t/how-to-customize-figure-size-and-other-things-with-using-graphmakie/122572/6 "2024-11-19T06:59:22Z")

</div>

I haven’t tried the linked workaround since it looks a bit complicated. But the [solution by mschauer](https://github.com/MakieOrg/GraphMakie.jl/issues/141#issuecomment-1759077321) works! Thanks.
