# PyPlot for PythonCall

**URL:** https://discourse.julialang.org/t/pyplot-for-pythoncall/79407
**Category:** Visualization
**Tags:** plotting, python, pythoncall
**Created:** [February 1, 2022, 9:25pm UTC](https://discourse.julialang.org/t/pyplot-for-pythoncall/79407 "2022-02-01T21:25:37Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![goerz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerz/32/3269_2.png) [@goerz](https://discourse.julialang.org/u/goerz)
#### Post date: [February 1, 2022, 9:25pm UTC](https://discourse.julialang.org/t/pyplot-for-pythoncall/79407/1 "2022-02-01T21:25:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)
#### Post date: [February 2, 2022, 3:40pm UTC](https://discourse.julialang.org/t/pyplot-for-pythoncall/79407/2 "2022-02-02T15:40:06Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [April 12, 2022, 10:52pm UTC](https://discourse.julialang.org/t/pyplot-for-pythoncall/79407/3 "2022-04-12T22:52:28Z")

</div>

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

- [https://github.com/stevengj/PythonPlot.jl](https://github.com/stevengj/PythonPlot.jl)

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.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [April 14, 2022, 2:27am UTC](https://discourse.julialang.org/t/pyplot-for-pythoncall/79407/4 "2022-04-14T02:27:20Z")

</div>

For tracking the corresponding port in Plots.jl, I filed: [https://github.com/JuliaPlots/Plots.jl/issues/4181](https://github.com/JuliaPlots/Plots.jl/issues/4181)
