Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Labels
Description
Bug summary
When setting up a simple animation on a TkAgg canvas, everything works as expected, until the XKCD-style is applied.
Code for reproduction
importtkinterastkfromdatetimeimportdate,datetimefromtkinterimportttkimportmatplotlib.animationaspltanimimportmatplotlib.pyplotaspltfrommatplotlib.axesimportAxesfrommatplotlib.backends.backend_tkaggimportFigureCanvasTkAggclassDayPlotFrame(ttk.Frame):"""TK Frame with matplotlib animation for live display of day progress."""def__init__(self,master=None):"""Initialize a new DayPlot."""super().__init__(master=master)plt.xkcd()# <- comment out this line and everything starts working againfig=plt.Figure()self.axes:Axes=fig.add_subplot()canvas=FigureCanvasTkAgg(fig,master=self)canvas.get_tk_widget().pack(fill=tk.BOTH,expand=True)self.animation=pltanim.FuncAnimation(fig,func=self.__run_animation,init_func=self.__init_animation, )self.pack()def__init_animation(self):"""Configure the plot."""today=date.today()self.axes.clear()self.axes.set_xlim(datetime(today.year,today.month,today.day,8,45,0),datetime(today.year,today.month,today.day,15,11,00), )def__run_animation(self,frame):"""Update the plot according to the time of day."""width=datetime.now().replace(hour=10,minute=frame%60)self.axes.barh(y=[1],width=width,color="blue")ROOT=tk.Tk()APP=DayPlotFrame(master=ROOT)APP.mainloop()
Actual outcome
coredump
Expected outcome
the animation, but in XKCD style
Additional information
the init_func works just fine, the crash happens at thebarh
statement
Operating system
Arch
Matplotlib Version
3.6.2
Matplotlib Backend
TkAgg
Python version
Python 3.9.2
Jupyter version
No response
Installation
pip