0

I am running the exact code as below which was a part of an answer for updating plots (see: How to update a plot in matplotlib). The problem is that the figure window never show up. The program runs and the python emblem starts to load but then it finishes without showing anything. Im on Mac and use VScode. Thanks for the help!

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 6*np.pi, 100)
y = np.sin(x)

# You probably won't need this if you're embedding things in a tkinter plot...
plt.ion()

fig = plt.figure()
ax = fig.add_subplot(111)
line1, = ax.plot(x, y, 'r-') # Returns a tuple of line objects, thus the comma

for phase in np.linspace(0, 10*np.pi, 500):
    line1.set_ydata(np.sin(x + phase))
    fig.canvas.draw()
    fig.canvas.flush_events()
  • The figure shows up for me with that code. So better check your IDE ... settings, it's not related to matplotlib, numpy. – MagnusO_O Oct 04 '22 at 16:46
  • Ah ok. You have any suggestion to what it could be? Im new to VS. – watcher6371 Oct 04 '22 at 16:53
  • You should edit your question, especially the tags. For that best check the [Tour](https://stackoverflow.com/tour), [How to ask a good question](https://stackoverflow.com/help/how-to-ask), & [On Topic](https://stackoverflow.com/help/on-topic). – MagnusO_O Oct 04 '22 at 17:00
  • Which IDE are you using? Just don't know what the error could be – watcher6371 Oct 04 '22 at 17:41

0 Answers0