How to create/display multiple plot windows in GR.jl?

I searched online and found no example of doing so; the API does not seem to contain function that supports this either. I already opened an issue at the GitHub project, but no response yet.

But this feature is often needed: creating and displaying multiple figure windows in a single script. My script often generates many figures, with each consisting of multiple subplots. Saving them to disk while only showing the last one is a workaround which wastes time (to open those files) and confuses users of the script.

I know how to do multiple plot windows in PyPlot.jl and Plots.jl, but I’m focused on GR.jl here because:

Although I love PyPlot.jl, the problem is I had various annoying issues due to Python distribution version and matplotlib backend compatibility. Sometimes if I do not choose qt4agg as backend, the whole Julia will crash due to some bizarre binary error (I’m on Windows 10). But some Python distribution didn’t have qt4agg installed by default. I’m concerned that co-workers using my script need to worry about not only packages on Julia but also packages on Python, resulting in resistance to adoption. In addition, plotting large data sets in PyPlot is a little slow.

I tried to like Plots.jl but couldn’t. There are too many plotting packages to choose from, each with its own advantages, disadvantages, and surprises. Main issue for me is I often generate plots with many subplots, and the outcome seems to be quite inconsistent across different backends for Plots.jl. Even the GR backend does not work all the time as expected for subplots.

So I’m back to the simpler GR.jl: the grammar is sufficiently close to Matlab and matplotlib that I can pick it up quickly, and I am confident my colleagues can, as well. Time to first plot is short and updates to plots are fast. And, no dependency on Python. The only 3 things I am missing are: (1) Multiple plot windows (this question); (2) Zoom / pan / 3D rotate / read data off the plots (in a default plot without custom coding). (3) Saving a plot’s data for re-opening as an interactive plot (matplotlib does not have this last one reliably either - one can serialize/de-serialize a binary object, but cannot re-open if saved by a different matplotlib version; only Matlab has this feature).

I can tolerate the lack of (2) and (3) for now, but (1) is so essential that before I learn how to do it, I have to stick with PyPlot.

Thanks to anyone who can give me some information on this topic!

See the code that I used for displaying multiple plots. You should just use display(plotReference) to show the plots. My plotReference is updated in each iteration of my loop.
I used Plots in the high-level code:

# using Pkg
# Pkg.add("Plots")
# Pkg.add("GR")
using Plots

Thank you for your reply!


(1) Can we avoid Plots.jl and use GR.jl only? See my original post for why I want to avoid Plots.jl.

(2) Even if I accept the use of Plots.jl with GR backend, a simplified copy of the example only generates plot one after another, with the latter overwriting the previous. Yes by saving each plot as picture one can always open all of them, but what I am looking for is for all plots to display simultaneously in different graph windows. (And yes I don’t use graph panes; rather I prefer individual plot windows just like what Matlab and matplotlib would do.)

Is this even possible in GR.jl by itself without using Plots.jl?

IMO, Plots is very nice, and it is quite the standard for plotting in Julia. it wraps GR or PyPlot and many others. Its main advantage is that you can use different backends with the same syntax, without changing the code, and without learning each backend.
SeeGR doc that recommends Plots:

For seeing all the plots in Atom in plot pane, you can press left and right arrows to see previous plots.

If you don’t want to use plot pane in Atom at all go
Go to Julia settings or run this code in REPL Julia>settings
Then uncheck “enable plot pane”

From Juno Atom documentation:

Using the Plot Pane

Use of the plot pane will be automatic by plotting packages which support the interface. The following describes the package interactions in more depth.

The Plots.jl Ecosystem

Plots.jl supports usage of the plot pane with compatible backends. The backends which are compatible are:

  • PlotlyJS
  • PyPlot
  • GR

The plot command will plot to the plot pane by default. To open up a non-plot pane window, use the gui() command. For example,

using Plots
pyplot() # Choose a backend
plot(rand(4,4)) # This will plot to the plot pane
gui() # This will open up a separate interactive GUI window

Thank you, Amin.

I know Plots are very nice. I played with Plots for a while but was not getting consistent results across different backends, especially for plots with subplots. Not sure if this is related to my OS which is Windows 10.