`Plots` or otherwise?

After 1.5 years of Julia experience, I now write almost everything in Julia. I used to use Bourne shell, Ruby, Fortran, and a bit of Haskell, but I don’t need these any longer. Except I don’t know which plotting package is the right one for me. (And except for some things that Haskell does very well, like lazy recursion.)

When I started Julia, I read one of the official Julia webpages, which said that Plot is the unified interface and you can switch backends to suit your needs. I thought, that’s a great idea!

So, since then, I’ve been exclusively using Plots. It’s much more elegant and easier to use than “traditional” plotting methods common in other languages and environments.

But I found it sometimes very hard to find information about Plots. I search Google and Julia Discourse, but almost always the information I find is exclusive to a particular package, like Makie and Matplotlib. The syntax I find there is totally different from Plots’s.

So, my question No.1 is: Is it possible to mix two ways?

using Plots
use_somebackend()
p = plot( . . . )
function_specific_to_the_backend(p, . . .) # or something like this.

Also, sometimes I ask questions about plotting in this forum and I often get an answer like “package X can do that” and I end up not knowing how to replicate it in Plots with X as the backend.

I don’t know whether it’s a problem of documentation of Plots or whether the capability isn’t accessible form Plots. I don’t think I understand the architecture of Plots.

I’m not talking about large things like contouring. I know contouring is available in Plots. I’m talking about smaller things, like having three or more y axes for a single graph, specifying the absolute positions of the axes, controlling the the precision of numeric labels, specifying fonts of the letterings, plotting an arbitrary polygons and arrows on an existing plot, open-ended contouring levels, specifying exact colors for contour levels, extending plot elements outside the plotting rectangle, availability of geographical maps (country boundaries, elevation of land surface, etc.) without plotting maps myself, availability of map projections, etc., etc.

These aren’t big things, but I need them and since I’m not able to find out how to do these with Plots, I give up Julia for producing figures and go back to an old plotting program I’m familiar with and have almost total control of.

I feel defeated.

So, my question No. 2 is, does Plots do almost everything and is it just a documentation problem? Or is it that Plots is still very young and its future is promising even if it doesn’t have those capabilities now? Or should I find a suitable package to me and learn its specific ways?

Then, supposing I’ll be migrating to another package, I still find it hard to decide on which one I should explore. Because I need to plot geographical maps, I search for it and find that GMT.jl seems to be a great package. But when I search for other capabilities, sometimes Makie.jl and sometimes another package, etc.

I’m a full-time researcher and I use programming languages and tools for my scientific work. I don’t have too much time to explore various packages before I decide on which one to go with.


As an aside . . . I’m the only Julia user among my colleagues as far as I know. A large fraction of my colleagues use Python or are switching to Python. It seems all of them use one well known plotting package. Is it called matplotlib? I then look over what matplotlib looks like and am dismayed to see its . . . how to put it . . . complicated user interface. I’m attracted to Julia, Ruby, and Haskell because of their elegance. The Plots package suits Julia very well.

Python just works but it doesn’t look fun to program in it. As far as I can tell from the tutorials, matplotlib looks like it’s not much fun.

3 Likes

Most of these are hard to offer with a unified syntax over multiple different backends because their implementations or APIs in the backends themselves differ so much. That’s why Plots doesn’t cover every possible feature, but a subset.

1 Like

No Plots definitely doesn’t do everything. Personally, I’ve found Plots to be the perfect plotting package for exploration. That is, to quickly look at things while I’m doing research, e.g., in a Jupyter Notebook. The package syntax is just very short and flexible. The multiple backends also come in handy. One of my favorites is UnicodePlots, which I love to use as part of running package tests in the terminal (but then switch to a different backend if I really need to see details).

However, Plots is not very good when you need extreme customization, most likely for generating plots for published papers. Personally, I’m still finding Python’s matplotlib unsurpassed, although Makie looks interesting if you’re looking for something in pure Julia.

8 Likes

I agree with @goerz . I use Plots.jl in my everyday programming/exploration but switch to PyPlot.jl (which is a one-to-one wrapper of matplotlib in Python) when I need to create publication-grade figures. I am quite curious about Makie.jl and have heard a lot good things and keep telling myself that I will try next time but that hasn’t happened so far :sweat_smile:

Here is a really good summary/comparison of the different plotting packages.

4 Likes

I tried many packages, and for 2D publication ready plots I switched back to PythonPlot.jl GitHub - JuliaPy/PythonPlot.jl: Plotting for Julia based on matplotlib.pyplot which is basically Matplotlib.

It is very mature, provides high quality 2D plots and it is easy to find documentation.

Only for 3D plots and animations I use Makie.jl

5 Likes

Thank you all for your inputs! It seems that this

is the consensus. That makes sense. I’ve been struggling to customize my plots for publication, but I use Plots quite often just to explore or to debug.

Thank you for that! The top page of Makie shows a few plots from my research field (meteorology, oceanography, climate science)!

Perhaps I’ll explore Makie first and if I’m defeated, I’ll come back to PyPlot.jl or PythonPlot.jl (What’s the difference between the two packages?).

Please file issues when you’re missing features :slight_smile: matplotlib due to its age and userbase has many niche use cases covered and I like to check those off one by one for Makie

1 Like

(What’s the difference between the two packages?).

One uses PyCall (earlier) the other PythonCall (newer). Otherwise, virtually identical.

1 Like

Hi, about plot quality, customizations etc and using in publications, I would like to point out that the GMT papers listed here

have collected in total some ~13500 citations.

2 Likes

Publication quality may mean many things (features or font control, etc), but for the most typical publication plots I find the default Plots + GR with some customization options quite satisfactory, and I didn’t feel the need to move to something else for the moment:

image

(from here)

ps: I don’t need all the resources you mentioned there, for sure.

5 Likes

I hope you’ll consider plotly too, either through PlotyJS.jl, the more light-weight PlotyLight.jl or in conjunction with those as a customistion step after using the backend via Plots.jl. I personally find it intuitive as a researcher who wants to get the job done, and it covers all the things you mentioned including some quick ways to do geographic plots. If you have any questions at all, feel free to get in contact here.

3 Likes

I should’ve mentioned that I’ve already published a scientific paper that includes a few line graphs (similar to the one you show) which I plotted with the Plots package :smile:

When I talk about “publication quality”, I certainly agree that the quality of plots from the Plots package is high, higher than those I’ve produced with other tools.

But that kind of “qtuality” isn’t what I’m after. I’ve hit the wall of customizability with Plots. That is, I need a different kind of “quality”.

To me, the current show stoppers of Plots are 1) the inability (or difficulty, I can’t tell which) of producing publication quality contour plots with open-ended contour intervals and 2) the inability of specifying the absolute positions of the axes. The margins can be precisely controlled but the axes shift depending on the letterings (labels) plotted outside the axes. I often need to align separately plotted figures and graphs but if the positions and lengths of the axes are different between the plots, the alignment requires a tedious trial-and-error.

For problem (1), I’ve found the PlotLy backend kind of produces not-too-bad plots, except that I can’t save them to image files because of a bug (it’s reported but taking some time). Then, I switched to another backend (pyplot?), which plotted a fine contour plot with open ended levels, but its contouring was with continuous color shading and without contour lines . . . Then I didn’t know how to get discrete color levels and also I had to manually overlay contour lines . . . You see, there is so much work before you get what you need.

I’ll likely discover other showstoppers as/if I keep using Plots. As I said in my initial posting, whenever a problem of customizability occurs, I search the net and Discourse, and was defeated in many cases.

Initially my Plot skill grew rapidly, but for this half year, it has stopped growing, having not been able to solve my problems.

1 Like

Sorry, would mind explain in more detail whay you mean here?

plots with open-ended contour intervals

If there is an easy way to upload an image, please tell me.

In words . . . suppose you have a 2D variable which ranges from -100 to 100, but you want to make a contour plot over -10 to 10 and you want to paint -100 to -10 with the lower extreme color and 10 to 100 with the higher extreme color. The colorbar must indicate the fact. The most common way is to have a little downward pointing triangle for the -100 to -10 range and an upward pointing triangle for the 10 to 100 range at the lower and upper ends of the colorbar.

In other words, I need contour levels of [-Inf, -10, -8, -6, . . . , 6, 8, 10, Inf] and I need the colorbar to indicate the fact. In my field, the standard plotting programs automatically do this.

I’ve submitted a feature request to the Plots package github to implement this feature for the GR backend.

I don’t understand what 1) means, but for 2) and for maximum publication quality in general, anything that produces pgfplots/LaTeX plots, like for example Pgfplotsx.jl, is unmatched. At least if by “publication quality” you are talking about LaTeX.

So, you don’t understand (2), either. Perhaps we should stop using the term “publication quality” altogether. Please go back to one of my previous posts to see what I mean by (2). I need to control the absolute positions of the axes from the edge of the produced image.

It’s not a quality issue. Let’s agree on that. It’s the lack of capability.

How can you tell that I don’t understand 2), I just said that pgfplots solves it, I didn’t explain what I thought ‘it’ was. Please re-read the sentence.

This is what pgfplots solves. It allows aligning axes, disregarding labels, ticks, etc.

Have you really look at it? Because it can do all the things you mentioned here.

Have you really look at it? Because it can do all the things you mentioned here.

I believe you. No, I haven’t looked at it carefully.

But, I don’t understand what you intend by that question. I didn’t dismiss GMT.jl.

All I’m saying is, I haven’t been able to find out how to produce what I need with Plots.jl. And I showed a few examples of that (because one person said that `Plots.jl’ is good enough.) That’s all.

Then, you folks indicate what I need can be accomplished by packages X, Y, Z, etc.

So, there is probably misunderstanding.

I’m not saying that what I want cannot be done by the existing packages. I expect what I need can be done by any graphics packages. That’s why I’m frustrated with Plots.jl in the first place.