# How to make a fast first plot with CairoMakie?

**URL:** <https://discourse.julialang.org/t/how-to-make-a-fast-first-plot-with-cairomakie/94120>\
**Category:** Visualization\
**Tags:** plotting, makie, cairo\
**Created:** [February 6, 2023, 6:38am UTC](https://discourse.julialang.org/t/how-to-make-a-fast-first-plot-with-cairomakie/94120 "2023-02-06T06:38:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![YH\_Ko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yh_ko/32/45438_2.png) [@YH\_Ko](https://discourse.julialang.org/u/YH_Ko)\
**Post date:** [February 6, 2023, 6:38am UTC](https://discourse.julialang.org/t/how-to-make-a-fast-first-plot-with-cairomakie/94120/1 "2023-02-06T06:38:17Z")

</div>

I’m new to Julia language.  
I have tried to follow data visualization with Makie.

 ![code](https://global.discourse-cdn.com/julialang/original/3X/f/e/feb04d7588136a381121a908e30b8da3e58f82c3.png)

However, the time to first plot is too long. (~50sec)  
50.087309 seconds (146.21 M allocations: 7.676 GiB, 3.69% gc time, 98.74% compilation time: 0% of which was recompilation)  
I know it is due to compilation process. And actual rendering time is about 150ms.  
What should I do to reduce the time to (first) plot??

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [February 6, 2023, 6:53am UTC](https://discourse.julialang.org/t/how-to-make-a-fast-first-plot-with-cairomakie/94120/2 "2023-02-06T06:53:01Z")

</div>

You might want to try Julia 1.9 (currently in beta).

---

<div class="post-metadata">

**Author:** ![TheLateKronos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thelatekronos/32/12824_2.png) [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Post date:** [February 6, 2023, 7:23am UTC](https://discourse.julialang.org/t/how-to-make-a-fast-first-plot-with-cairomakie/94120/3 "2023-02-06T07:23:05Z")

</div>

To elaborate on the previous answer, Julia 1.9 allows “native code caching”, which makes Time To First X (TTFX) significantly faster in many cases.

An alternative is to make a system image. It is a little cumbersome, but gives the largest reduction in TTFX. See [the vscode-guide to sysimages](https://www.julia-vscode.org/docs/dev/userguide/compilesysimage/), and the [PackageCompiler.jl page on sysimages](https://julialang.github.io/PackageCompiler.jl/stable/sysimages.html) for more information about the sysimage approach.

But I would generally recommend a new user to just use 1.9 beta (Easy to upgrade if you use a Julia installer system [juliaup](https://github.com/JuliaLang/juliaup) or [jill.py](https://github.com/johnnychen94/jill.py)), or wait until the non-beta release to have the problem significantly alleviated. As 1.9 is in the third beta release, I do not think it is many week away.
