PyPlot for PythonCall

The PyPlot backend for Plots.jl only works with PyCall, right? How hard would it be to make work with PythonCall instead (so I don’t even have to have PyCall installed). I’d very much appreciate the full environment isolation that PythonCall promises.

I know I can use matplotlib directly, but I like the more abstract Plots.jl interface so that I can switch backends on the fly

2 Likes

As far as I understand, that’s right: you must have PyPlot and PyCall to use the PyPlot backend. Looking at the code though, I don’t think it would be too difficult to copy+paste the backend, give it a new name and modify it to call out to PyPlot directly via PythonCall.

1 Like

I made a first pass at porting PyPlot to PythonCall, as an experiment. The result is here:

It seems to work in a Jupyter notebook, but the standalone GUI backends aren’t functional yet. (Initializing a Matplotlib backend is a pain.) and the GUI backend (defaulting to Tk) seems to work too.

It’s still only lightly tested, though, so please bang on it and file issues if you encounter a problem.

18 Likes

For tracking the corresponding port in Plots.jl, I filed: [FR] PythonPlot/PythonCall alternative to PyPlot/PyCall · Issue #4181 · JuliaPlots/Plots.jl · GitHub