all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Python Matplotlib with MPLBACKEND TkAgg
@ 2024-04-19  0:58 Jake
  0 siblings, 0 replies; only message in thread
From: Jake @ 2024-04-19  0:58 UTC (permalink / raw)
  To: help-guix

Hi

I'm not sure how to get Python's Matplotlib to plot using the MPLBACKEND
TkAgg without hardcoding it in the python script.

I can get the WebAgg backend to work by setting the MPLBACKEND env var:

#+begin_src sh

  guix shell python python-matplotlib python-tornado -- bash -c
'MPLBACKEND=WebAgg python3 -c "import matplotlib;
print(matplotlib.get_backend()); import matplotlib.pyplot as plt;
plt.plot([1],[2]); plt.show()"'

#+end_src

#+RESULTS:
: WebAgg
: Press Ctrl+C to stop WebAgg server

This approach doesn't seem to work for the TkAgg backend:

#+begin_src sh

  guix shell python python-matplotlib -- bash -c 'MPLBACKEND=TkAgg python3
-c "import matplotlib; print(matplotlib.get_backend()); import
matplotlib.pyplot as plt; plt.plot([1],[2]); plt.show()"'

#+end_src

#+RESULTS:
: TkAgg
: <string>:1: UserWarning: FigureCanvasAgg is non-interactive, and thus
cannot be shown

The TkAgg backend does work if I hardcode it in the Python script using
`matplotlib.use()`, but this approach is undesirable:

#+begin_src sh

  guix shell python python-matplotlib -- python3 -c "import matplotlib;
matplotlib.use('TkAgg'); print(matplotlib.get_backend()); import
matplotlib.pyplot as plt; plt.plot([1],[2]); plt.show()"

#+end_src

#+RESULTS:
: TkAgg

Thanks in advance!

Jake

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-19  0:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-19  0:58 Python Matplotlib with MPLBACKEND TkAgg Jake

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.