From: Jake <jforst.mailman@gmail.com>
To: help-guix@gnu.org
Subject: Python Matplotlib with MPLBACKEND TkAgg
Date: Fri, 19 Apr 2024 00:58:58 +0000 [thread overview]
Message-ID: <CAJqVjv9-_z+7g4bTDOCdw55EH176GsO09F02A6xs3vPGguSU6Q@mail.gmail.com> (raw)
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
reply other threads:[~2024-04-19 0:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJqVjv9-_z+7g4bTDOCdw55EH176GsO09F02A6xs3vPGguSU6Q@mail.gmail.com \
--to=jforst.mailman@gmail.com \
--cc=help-guix@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.