Python Tkinter中matplotlib图形周围的黑框
我在Tkinter框架中嵌入一个pyplot图。在整个人像周围有一条很粗的黑线,我想去掉它。它仅在“我的Tkinter”窗口处于活动状态时出现: 我正在MacOS10.9上使用Python2.7.6。这是我的密码:Python Tkinter中matplotlib图形周围的黑框,python,matplotlib,tkinter,Python,Matplotlib,Tkinter,我在Tkinter框架中嵌入一个pyplot图。在整个人像周围有一条很粗的黑线,我想去掉它。它仅在“我的Tkinter”窗口处于活动状态时出现: 我正在MacOS10.9上使用Python2.7.6。这是我的密码: from Tkinter import * import matplotlib.pyplot as plt from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg class PlotFrame(Frame)
from Tkinter import *
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
class PlotFrame(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.fig = plt.figure()
self.plot = self.fig.add_subplot(1, 1, 1)
self.canvas = FigureCanvasTkAgg(self.fig, master=self)
self.canvas.show()
self.canvas.get_tk_widget().grid(row=0, column=0, sticky=(N), padx=20, pady=20)
root = Tk()
plot_frame = PlotFrame(root)
plot_frame.grid(row=0, column=0)
root.mainloop()
谢谢 由画布小部件的
highlightthickness
和highlightcolor
属性控制。如果不想看到,请将highlightthickness
设置为零 这对我来说很管用,只是做了一点小小的修改。由于我的画布是FigureCanvasTkAgg
的一个实例,我必须通过self.canvas.\u tkcanvas.config(highlightthickness=0)
而不是self.canvas.config(highlightthickness=0)
更新highlightthickness
。