Using PyPlot vs Plots

Hi,

When I first learned Julia, I was guided towards the Plots package for visualization. Even though it has multiple options of the backend libraries, I found it hard for me as a user who is more familiar with the MATLAB and Python plotting syntax to use it smoothly. After a while I found the PyPlot package, which is more stable and robust currently so I’m mostly using it for plotting now.

Does the Plots package actually supports all the features in PyPlot? For example, can I call streamplot from Plots? How can I do streamline plotting in Plots?

Is there any general recommendation for using the different plotting packages?

No there is no general recommendation which package to use. If you are satisfied with PyPlot, just stick with that. It has the advantage that you can transfer most python examples of Matplotlib directly to Julia.

So basically all backends for Plots.jl can be used in a stand alone variant. Here the overview from the link above:

If you require… … then use…
features PyPlot, Plotly(JS), GR
speed GR, InspectDR
interactivity Plotly(JS), PyPlot, InspectDR
beauty Plotly(JS), PGFPlots
REPL Plotting UnicodePlots
3D plots PyPlot, GR, Plotly(JS)
a GUI Window GR, PyPlot, PlotlyJS, InspectDR
a small footprint UnicodePlots, Plotly
plot+data -> .hdf5 file HDF5

While this Backends ar all supported by Plots.jl there are even more plotting/visulaisation packages:
Gadfly.jl
Makie.jl
Winston.jl
KittyTerminalImages.jl

There are even more (discontinued) packages, so this list ist not complete.

Does the Plots package actually supports all the features in PyPlot? For example, can I call streamplot from Plots? How can I do streamline plotting in Plots?

I don’t think so. But as @tobias.knopp wrote already, it ist absolutely fine to stick with PyPlot if it fulfills its purpose. Personally I usually use a library where the documentation is extensive

3 Likes

Plots is a general system for plotting in Julia which has a nice recipe system that allows packages to easily setup “auto-plotting”. There’s a lot documented with it since plot(x) “just works” with a lot of package outputs, even if the types are recursively complicated. That said, it isn’t without its issues. If you’re familiar with PyPlot though, feel free to write routines to extract vectors and plot the vectors: it’s a perfectly fine package.

Plots.jl doesn’t wrap all of the features, but it also extends the backends with “series recipes”. For example, grouped bar plots is something it’s able to add to the backends by drawing it directly. However, one thing that it’s missing is full support for trisurfs and quiver plots, which PyPlot.jl does quite nicely. GR.jl is also a good plotting package, I’d usually prefer it since it’s a whole lot faster on big data, but last I looked its trisurfs needed a few more pieces to really work in FEM plotting contexts. Makie.jl is a pure Julia solution with lots of support for interactivity, direct drawing, 3D, and the works, but it still needs a little polish here and there.

The hope is that Makie.jl soon gets a recipe system and we’d basically get the best of all worlds. It would also allow type-codifying a lot of the weirder conventions that usually happen in plotting packages as long lists of arrays.

4 Likes

In the past two months, Hayden Klok and I have been revising our “Statistics with Julia” draft to use Plots.jl (and StatsPlots.jl) instead of PyPlot.jl. At the moment the online draft version still uses PyPlot, however we’ll be able to update to the new version within the next few weeks.

Our experience was very positive. In general, converting the code base from PyPlot to Plots.jl reduced the code length by about 20% while keeping the same quality of images.

2 Likes

Glad to hear that. I read the first few chapters last month. Looking forward to the new version!

1 Like

@yoninazarathy, do you have an estimate of when your book will be published ? The draft looks very interesting, thanks for sharing.