-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PyPlot equivalent? #105
Comments
Matplotlib should just work: plt = pyimport("matplotlib.pyplot")
plt.plot(rand(100))
plt.show() There are a few helpers noted here: https://cjdoris.github.io/PythonCall.jl/stable/compat/#MatPlotLib-/-PyPlot-/-Seaborn |
Sorry for bothering again! I somehow got stuck at installing Matplotlib with When importing Matplotlib, it complained to me first about (v1.7) pkg> conda status
CondaPkg Status /home/hongyang/.julia/environments/v1.7/CondaPkg.toml
Packages
pygobject v3.42.0
matplotlib v3.5.1
cairo v1.16.0
numpy v1.22.2
python v3.10.2
pycairo v1.20.1
pyqt v5.12.3
julia> plt = pyimport("matplotlib.pyplot")
ERROR: Python: ImportError:
Python stacktrace:
[1] <module>
@ ~/.julia/environments/v1.7/.CondaPkg/env/lib/python3.10/site-packages/matplotlib/backends/backend_gtk3.py:29
[2] <module>
@ ~/.julia/environments/v1.7/.CondaPkg/env/lib/python3.10/site-packages/matplotlib/backends/backend_gtk3agg.py:8
[3] import_module
@ importlib ~/.julia/environments/v1.7/.CondaPkg/env/lib/python3.10/importlib/__init__.py:126
[4] backend_mod
@ ~/.julia/environments/v1.7/.CondaPkg/env/lib/python3.10/site-packages/matplotlib/pyplot.py:268
[5] switch_backend
@ ~/.julia/environments/v1.7/.CondaPkg/env/lib/python3.10/site-packages/matplotlib/pyplot.py:267
[6] <module>
@ ~/.julia/environments/v1.7/.CondaPkg/env/lib/python3.10/site-packages/matplotlib/pyplot.py:2230
Stacktrace:
[1] pythrow()
@ PythonCall ~/.julia/packages/PythonCall/B5irB/src/err.jl:94
[2] errcheck
@ ~/.julia/packages/PythonCall/B5irB/src/err.jl:10 [inlined]
[3] pyimport(m::String)
@ PythonCall ~/.julia/packages/PythonCall/B5irB/src/concrete/import.jl:11
[4] top-level scope
@ REPL[6]:1 Anything I shall try to fix this Conda dependency issue? |
Does this happen in a fresh Julia session? What about if you do |
Yes this is a fresh installation of >>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "/home/hongyang/.julia/environments/v1.7/.CondaPkg/env/lib/python3.10/site-packages/matplotlib/backends/backend_gtk3.py", line 25, in <module>
gi.require_version("Gtk", "3.0")
File "/home/hongyang/.julia/environments/v1.7/.CondaPkg/env/lib/python3.10/site-packages/gi/__init__.py", line 126, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gtk not available Now it seems that I need GTK+ libs for Python, but I don't know what exact libraries they are... |
Try a different MPL backend, like Qt5Agg? Actually can you try again in a fresh Conda environment outside of Julia? I'm trying to establish if this is an issue with MPL or PythonCall. |
Switching to the Qt+ backend works for me under the following conda environments: (v1.7) pkg> conda status
CondaPkg Status /home/hongyang/.julia/environments/v1.7/CondaPkg.toml
Packages
pygobject v3.42.0
matplotlib v3.5.1
numpy v1.22.2
python v3.10.2
pycairo v1.20.1 julia> using PythonCall
julia> mpl = pyimport("matplotlib")
Python module: <module 'matplotlib' from '/home/hongyang/.julia/environments/v1.7/.CondaPkg/env/lib/python3.10/site-packages/matplotlib/__init__.py'>
julia> mpl.use("qtagg")
Python None
julia> plt = pyimport("matplotlib.pyplot")
Python module: <module 'matplotlib.pyplot' from '/home/hongyang/.julia/environments/v1.7/.CondaPkg/env/lib/python3.10/site-packages/matplotlib/pyplot.py'>
julia> plt.plot(rand(100))
Python list: [<matplotlib.lines.Line2D object at 0x7f932fef91e0>]
julia> plt.show()
Python None
|
Ok great. Closing the issue but feel free to ask more. |
Hi,
Thanks for sharing this package! Since I haven't found anything related to Matplotlib in the doc, it makes me wondering if there is kind of a PyPlot.jl equivalent workflow that is enabled by this package? If so, will there be any limitations compared with PyPlot.jl?
The text was updated successfully, but these errors were encountered: