Fastest plotting library?

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.

2 Likes

@StatisticalMouse, this booklet by Tufte, seems to have made some history.

5 Likes

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.

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

I tried some font identifying with Google and 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

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

1 Like

Gil Sans is a system font in MacOS and iOS.

ET Book I found here: ET Book · Edward Tufte on GitHub

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.

1 Like

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 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

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.

6 Likes

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:

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.

6 Likes

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.

4 Likes

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

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?

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

1 Like

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

What about lmPlot?

1 Like

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! :rofl:

1 Like

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.

1 Like