0

i am having issues with matplotlib animations when using xlwings, example from matplotlib:

import matplotlib.pyplot as plt
import numpy as np
import matplotlib.animation as animation

import xlwings as xw

fig, ax = plt.subplots()

x = np.arange(0, 2*np.pi, 0.01)
line, = ax.plot(x, np.sin(x))

def animate(i):
    line.set_ydata(np.sin(x + i / 50))  # update the data.
    return line,

ani = animation.FuncAnimation(
    fig, animate, interval=20, blit=True, save_count=50)

plt.show()

i get the following error:

UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.

this works fine when i do not use xlwings

1 Answer 1

0

I was able to fix this by setting the backend after importing xlwings:

import xlwings as xw

import matplotlib
matplotlib.use('TkAgg')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.