Hi cdb experts.
I am in the
- Jupyter notebook with Cadabra2 kernel
- Ubuntu 22.04
When trying to use matplotlib, I get the error
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
and when I specifically set the backend to TkAgg I get
UserWarning: Matplotlib is currently using TkAgg, which is a non-GUI backend, so cannot show the figure
even though Tk is a GUI backend.
I have set the pythonpath to
PYTHONPATH=/usr/lib/python3.10/:/usr/lib/python3.10/dist-packages:/usr/lib/python3.10/tkinter/
and I do have both matplotlib and tkinter ("python3-tk") installed. What am I doing wrong, please?
Thank you!
P.S. As an example, the following code produces said error:
import matplotlib.pyplot as plt
from cdb.core.component import *
{i,j,k,l,m,n}::Indices(rotation, values={1,2,3}).
\epsilon{#}::EpsilonTensor.
Ki := (K_{i})_{m n} = \epsilon_{i m n}.
evaluate(Ki, rhsonly=True);
fig = plt.figure()
with plt.rc_context({'backend':'tkagg'}):
for i in range(3):
for j in range(3):
val = get_component(Ki, $1, 0, 0$)
plt.text(i,j,str(val), va='center',ha='center')
plt.show()
Many thanks!