# Fastest plotting library?

**URL:** <https://discourse.julialang.org/t/fastest-plotting-library/62018>\
**Category:** Visualization\
**Created:** [May 28, 2021, 8:42pm UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018 "2021-05-28T20:42:46Z")\
**Posts on this page:** 14\
**Page:** 3

<div class="post-metadata">

**Author:** ![StatisticalMouse](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/statisticalmouse/32/43370_2.png) [@StatisticalMouse](https://discourse.julialang.org/u/StatisticalMouse)\
**Post date:** [June 2, 2021, 7:32pm UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018/42 "2021-06-02T19:32:08Z")

</div>

There was some discussion above about what plots look good, and what don’t… Personally, the best plots I’ve seen have been in Edward Tufte’s books, physical books. I’ve been considering if I should just order the whole set of them. My former employer had a couple.

No, the Tufte-like computer plots are nowhere near as good looking as those that have probably been drawn by hand. There also aren’t many pictures online.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [June 3, 2021, 12:04am UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018/43 "2021-06-03T00:04:08Z")

</div>

@StatisticalMouse, [this booklet](https://www.google.com/url?q=https://canvas.harvard.edu/files/6632917/download%3Fdownload_frd%3D1&sa=U&ved=2ahUKEwjekbX9k_rwAhUB-hQKHbxUAKA4ChAWMAN6BAgHEAE&usg=AOvVaw2dHzi2cbR1yw1GigvuJhrT) by Tufte, seems to have made some history.

---

<div class="post-metadata">

**Author:** ![purplishrock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/purplishrock/32/13451_2.png) [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Post date:** [June 3, 2021, 1:04am UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018/44 "2021-06-03T01:04:54Z")

</div>

I have been trying to promote the use of Julia at my workplace.

The very first person that tried it out for actual work came to me with,

> I tried to use Plots with the blah-blah-blah backend and it doesn’t work.

I don’t remember what the back-end was. Now i tell everyone up-front, use PyPlot.

They can figure out a better option, if there is one _for what they need to do_, later.

---

<div class="post-metadata">

**Author:** ![StatisticalMouse](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/statisticalmouse/32/43370_2.png) [@StatisticalMouse](https://discourse.julialang.org/u/StatisticalMouse)\
**Post date:** [June 3, 2021, 1:17am UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018/45 "2021-06-03T01:17:08Z")

</div>

Thanks, that looks pretty good on this 10.5” ipad pro.

I tried some font identifying with Google and [WhatTheFont](https://www.myfonts.com/WhatTheFont/), which worked reasonably well, or at least better than a couple of other font-identifying services.

Then found this in [https://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg\_id=00009r](https://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=00009r)

In general, I use Gill Sans and ETBembo for everything in print; those typefaces are beautiful and work for my purposes. There is no content-need to develop new typographic styles for my work. There are too many substantive matters to think about and thus I want to limit the number of design decisions. Thus I try not to re-open solved typographic designs.

– Edward Tufte

---

<div class="post-metadata">

**Author:** ![StatisticalMouse](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/statisticalmouse/32/43370_2.png) [@StatisticalMouse](https://discourse.julialang.org/u/StatisticalMouse)\
**Post date:** [June 3, 2021, 1:21am UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018/46 "2021-06-03T01:21:19Z")

</div>

Gil Sans is a system font in MacOS and iOS.

ET Book I found here: [ET Book · Edward Tufte on GitHub](https://edwardtufte.github.io/et-book/)

ET Book is a Bembo-like font for the computer designed by Dmitry Krasny, Bonnie Scranton, and Edward Tufte. It is free and open-source.

It was used in Beautiful Evidence, and some of his other digitally released books. Tufte’s earlier books on analytical design were set in real lead in Monotype Bembo. While Monotype Bembo was an excellent book font, when converted to an electronic font, it became thin and spindly (the computer people ignored “squeeze”, the slight spreading of ink when the lead type hits the paper). So he, Krasny, and Scranton made their own computer version and also made some design changes (ligatures, several problems with the pi font, some letterforms, creation of a semibold). Adam Schwartz converted the digital font into a webfont and created this project, which exists on GitHub.

---

<div class="post-metadata">

**Author:** ![EvoArt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evoart/32/25357_2.png) [@EvoArt](https://discourse.julialang.org/u/EvoArt)\
**Post date:** [June 3, 2021, 6:08am UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018/47 "2021-06-03T06:08:29Z")

</div>

Speaking of Tufte… and showcasing Julia… and choice if plotting library.

I’m putting my notes/problem solutions from a mathematical biology book into a nice pdf that I hope to share with students from my university, once it’s finished. I’m using Weave.jl with a custom template that uses the [Tufte-handout](https://ctan.org/pkg/tufte-latex?lang=en) class. Plotting a symbolic equation is straight forward using Plots.jl recipes defined by Symbolics.jl and thus shows the elegance of Julia. Setting chunck options

```julia
fig_env = "marginfigure", fig_pos = "-2cm"

```

(You have to put something in `fig_pos` )  
Will put your plot in the margin if you so desire.

Took me a bit to figure out I could use tufte styles and marginfigures directly in weave.jl. so I thought I’d share.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [June 3, 2021, 6:37am UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018/48 "2021-06-03T06:37:37Z")

</div>

> [@GregR](#):
>
> But indeed PGFPlotsX is slow.

If using PGFPlotsX for multiple figures, make sure you are not generating one figure per pdf but instead put multiple figures into the same pdf. As an example:

```julia
x = range(-1; stop = 1, length = 51);
axises = [@pgf Axis(
    {
        xmajorgrids,
        ymajorgrids,
    },
    Plot(
        {
            no_marks,
        },
        Coordinates(x, 1 ./ (x.-i))
    )
)
for i in 1:10];

@time for (i, axis) in enumerate(axises)
    pgfsave("file_$i.pdf", axis)
end
# ~ 5 seconds

td = TikzDocument([TikzPicture(axis) for axis in axises]);
@time pgfsave("file.pdf", td);
# ~0.8 seconds

```

You can then easily split out the individual plots from the pages of the pdf.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [June 3, 2021, 10:34am UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018/49 "2021-06-03T10:34:30Z")

</div>

> [@GregR](#):
>
> But indeed PGFPlotsX is slow. But there are a couple of things to mitigate this.

I find that using the `lualatex` engine (which PGFPlotsX should use automatically when available), speeds are reasonable. TeX, as originally designed, is not really suitable for the kind of computation that `pgfplots` (the LaTeX package) does.

That said, these days I try to keep my plots simple and clean (contours instead of overplotted scatter, etc) which results in graphics with a few primitives, so I get \<2s compilation times on most of my plots. Not great, not terrible.

---

<div class="post-metadata">

**Author:** ![GregR](https://avatars.discourse-cdn.com/v4/letter/g/e68b1a/32.png) [@GregR](https://discourse.julialang.org/u/GregR)\
**Post date:** [June 4, 2021, 1:36pm UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018/50 "2021-06-04T13:36:17Z")

</div>

I tried the 2 options, and did not observe a difference in speed.

---

<div class="post-metadata">

**Author:** ![Iulian.Cioarca](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iulian.cioarca/32/30166_2.png) [@Iulian.Cioarca](https://discourse.julialang.org/u/Iulian.Cioarca)\
**Post date:** [June 16, 2021, 12:15pm UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018/51 "2021-06-16T12:15:08Z")

</div>

Coming back to performance comparisons, I found Plots(Gr) and Gaston to be similar in terms of plotting and saving speed.  
However, I observed that the savefig time scales with the number of points. Although convenient for small number of points(beating Matlab), it gets slow for plots with tens of thousands of points. Matlab has constant saving time (1-2s).  
Any suggestion on how to improve this?

```julia
function test_Plots(npts, nlines)
	t = LinRange(0,1,npts)
	y = randn(length(t))
	h=Plots.plot(t, y, title = "Lines", label = "Line 0")
	for i=1:nlines
		Plots.plot!(t, i .* y, label = "Line $i")
	end
	x=rand(1:1000)
	@time Plots.savefig("C:\\Julia\\plot\\pic$x.png")
	nothing
end

test_Plots(100, 10) # 0.121…
test_Plots(1000, 10) # 0.330...
test_Plots(10000, 10) # 2.32…

```

'\* Tested, of course, multiple times

---

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [June 16, 2021, 7:29pm UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018/52 "2021-06-16T19:29:30Z")

</div>

I would probably compare the other options, like VegaLite, Gadfly, GLMakie, and Gnuplot.jl. Gnuplot in particular is probably fast.

---

<div class="post-metadata">

**Author:** ![Juan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juan/32/7657_2.png) [@Juan](https://discourse.julialang.org/u/Juan)\
**Post date:** [June 17, 2021, 2:20pm UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018/53 "2021-06-17T14:20:38Z")

</div>

What about lmPlot?

> **[GitHub - wsphillips/ImPlot.jl: Plotting extension library for CImGui.jl](https://github.com/wsphillips/ImPlot.jl)**
>
> Plotting extension library for CImGui.jl. Contribute to wsphillips/ImPlot.jl development by creating an account on GitHub.

> [@\[ANN\] ImPlot.jl -- FAST real-time plotting for CImGui.jl](https://discourse.julialang.org/t/ann-implot-jl-fast-real-time-plotting-for-cimgui-jl/43087):
>
> I wrapped a really nice plotting extension called [implot](https://github.com/epezent/implot), a C++ plugin for [Dear ImGui](https://github.com/ocornut/imgui). With some clutch help from @Gnimuc and the magic of BinaryBuilder.jl this package can be imported into a Julia session that’s using CImGui.jl and everything should “JustWork”. The plotting is straight forward and, notably, quite fast even with 100s of thousands of points. There’s also optional arguments to do strided/offset array access for interleaved data. Generally a nice solution for anyone that wants to…

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [June 19, 2021, 7:36am UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018/54 "2021-06-19T07:36:58Z")

</div>

> [@jzr](#):
>
> I would probably compare the other options

And there is the underrated `UnicodePlots`, which is what I use for personal consumption and should be pretty fast.

I confess: I still haven’t migrated to Julia for publication plots: I use either `TikZ+PGFPlots` (for diagrams, timelines, and such) or R’s `ggplot2` (for data, exporting and importing data between Julia and R). The main reason is that when I started using Julia, plotting packages weren’t as mature as they are now. I often found that I needed one package for one type of plot (say a stem-and-leaf plot), and another package for another type (say a 3d phase diagram). And they wouldn’t look great side by side because of different fonts and styles. If I learned how to control tick lengths with one package, I’d have it all to learn again for another package. I didn’t fight it very long and retreated to what I already knew. However, the problem these days is quite different: too many choices! 🤣

---

<div class="post-metadata">

**Author:** ![wsphillips](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wsphillips/32/6777_2.png) [@wsphillips](https://discourse.julialang.org/u/wsphillips)\
**Post date:** [June 26, 2021, 6:35pm UTC](https://discourse.julialang.org/t/fastest-plotting-library/62018/55 "2021-06-26T18:35:10Z")

</div>

> [@Juan](#):
>
> What about lmPlot?

If the OP wants to save output as PNGs to disk, ImPlot.jl is a poor choice–there’s no backend for producing figures/saving visualizations. It’s strictly for looking at your data interactively, monitoring streaming data, etc and embedding those visualization into GUIs built with CImGui.jl

From the implot FAQ:

> **Q: Is ImPlot the right plotting library for me?**
> 
> A: If you’re looking to generate publication quality plots and/or export plots to a file, ImPlot is NOT the library for you. ImPlot is geared toward plotting application data at realtime speeds. ImPlot does its best to create pretty plots (indeed, there are quite a few styling options available), but it will always favor function over form.

[Previous page](https://discourse.julialang.org/t/fastest-plotting-library/62018.md?page=2)
