Home > Enterprise >  how to change bg color of a FigureCanvasTkAgg in tkinter
how to change bg color of a FigureCanvasTkAgg in tkinter

Time:10-01

I want to Change the color of the white Part from the photo

Photo

Code:


        fig = matplotlib.figure.Figure(figsize=(2,1.5))
        ax = fig.add_subplot(111)
        ax.pie([100  , a]) 


        circle=matplotlib.patches.Circle( (0,0), 0.7, color='#171717')
        ax.add_artist(circle)

        
        canvas = FigureCanvasTkAgg(fig, master=App )
        canvas.get_tk_widget().place(x = 250 , y = 150)
        canvas.draw()

CodePudding user response:

You can pass facecolor as a parameter in Figure:

fig = matplotlib.figure.Figure(figsize=(2,1.5), facecolor="black")

Or use the set_facecolor method:

fig = matplotlib.figure.Figure(figsize=(2,1.5))
fig.set_facecolor("black")
  • Related