Fastest plotting library?

I need to generate a lot of plots(thousands) and save them to disk as png. Nothing fancy, just some scatter plots with legend, preferably with the option to adjust the resolution(number of points per plot is less than 1000). I’m not concerned about the time to first plot because all the plots are generated in the same session.
What library would be best suited for this task? (I’am also aware about disk write latency, but I want to squeeze as much performance as possible).

1 Like

It probably depends on what is in your plots, but I wouldn’t be surprised if GLMakie is faster than many.

1 Like

Plots.jl recommends GR or InspectDR for speed: Backends · Plots . (Note that Makie is not one of the choices it considers.)

3 Likes

Just for reference, using Gaston (a front-end for Gnuplot), after running all plot commands once:

julia> x=rand(1000); y=rand(1000);
julia> @time begin scatter(x,y,legend="'test'"); save(term="png",output="temp.png"); end
  0.020856 seconds (4.19 k allocations: 948.750 KiB)

It scales pretty well:

julia> @time begin
       for i in 1:100
       x=rand(1000); y=rand(1000);
       scatter(x,y,legend="'test_$i'")
       save(term="png",output="test_$i.png")
       end
       end
  2.036505 seconds (419.97 k allocations: 93.943 MiB, 0.58% gc time)
6 Likes

GMT produces the best looking plots but I normally wouldn’t bet on it to be the fastest. However your case has one characteristic that might be exploitable. GMT plots are made up of layers of plots. If you have a base layer with the frame legend and so on that is common to all plots you only need to create it once and append the specifics of each plot to this base layer.

2 Likes

I do wonder what is the use case for having thousands of plots?

5 Likes

Does it? GMT looks good for maps, but GrammarOfGraphics/Makie looks a lot nicer for line/scatterplots. For LaTeX, PGFPlots(x) is aesthetically unsurpassed, but slow.

2 Likes

Really? I would like to see a proof.

Makie: Lazaro Alonso

Agree PGFPlotsX looks great but it is slow.

https://kristofferc.github.io/PGFPlotsX.jl/stable/examples/gallery.html

1 Like

I agree that people who know what they’re doing can produce really nice looking graphics in Makie, but I feel that the defaults are pretty darned ugly, and I really don’t know what I’m doing well enough to fix that. If other packages provide defaults that I like and can use well without being an expert, I’ll usually just use those.

10 Likes

Could you give an example of a default Makie plot that you don’t like?

Almost all the plots here: https://makie.juliaplots.org/dev/basic-tutorial.html

I hope this isn’t coming off too harshly. I think Makie is a really cool project. I just don’t like it’s default aesthetic and I always found it pretty hard to produce plots with it where I did like the aesthetic. Hopefully once there’s a good theme ecosystem for Makie, it’ll be easier to make plots I like.

7 Likes

All the plot elements look a little fuzzy around the edges there. I wonder what that’s about. (cc @jules )

Several examples here: http://juliaplots.org/AlgebraOfGraphics.jl/dev/generated/penguins/

What does that prove? You said they look a lot nicer that the GMT plots. Where are the lot less nicer ones to compare to?

What are talking about ‘prove’? I gave my opinion, based on examples I’ve seen. Compare with this, for example: Some examples · GMT

It looks fine, no criticism, as good as many others. But the algebra of graphics ones are the nicest ones I’ve seen, next to PGFPlots for LaTeX.

I really don’t want to put down gmt, it feels petty, I just reacted to the flat out statement that they are the best.

4 Likes

I have a coworker who was generating plots based on various simulation conditions. each plot was necessary for documentation as each simulation required an associated plot as “evidence”. The generation of each simulation was automated and then, of course, the associated plot as well.

Done using julia and pyplot and generated (i think) about 1000 plots (might have even been close to 2000) and wrote them all to disk in about 15-20 minutes or so, including time it took to read the data to generate the plots.

What i’m unsure of is if julia was repeatedly called as a script or whether the generation was looped within a single script, as that would make a big difference in total run time.

3 Likes

If that is the case OP should really look at GitHub - dmolina/DaemonMode.jl: Client-Daemon workflow to run faster scripts in Julia

1 Like

The use case would be interesting. @Iulian.Cioarca are you making lots of plots which are going to be included as frames in an animation ?

That’s like the least helpful kind of critique. Everything’s just ugly (thanks for that, specifying in what way would have been at least a bit useful).

Regarding the fuzziness, yes GLMakie has a fuzziness issue because it can’t supersample yet, and the gpu drawn glyphs are not hinted. But in most cases not involving volume plots or similar, for high quality export CairoMakie should be preferred because it doesn’t have to take some of the “shortcuts” that the fast OpenGL implementation needs.

3 Likes