Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug]: coredump when combining xkcd, FigureCanvasTkAgg and FuncAnimation #24908

Open
@bbbart

Description

@bbbart

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp