【发布时间】:2019-12-19 19:54:04
【问题描述】:
我正在尝试在以下位置绘制网格:
from matplotlib.figure import
figure = Figure(figsize=(10, 10))
a = figure.add_subplot(111)
a.plot(x, y, '-r')
canvas = FigureCanvasTkAgg(figure, master=window)
canvas.get_tk_widget().pack()
NavigationToolbar2Tk(canvas, plotWindow)
canvas.draw()
plotWindow 只是一个 tkinter.Frame 对象
提前致谢:)
【问题讨论】:
-
你需要matplot吗?像通常在
matplot中一样绘制线条。你可以使用即。x=[0,0] y=[-100,100]绘制垂直线和即。x=[-100,100] y=[0,0]绘制水平线。Matplot还具有 .grid() 显示网格的功能。但这一切都与tkinter.Canvas无关。 -
@furas 是的,我确实尝试过 .grid(),但我从来没有 .show() 我的情节,所以它不起作用(当它弹出另一个窗口时)。我什至不使用 matplotlib.plot,只使用 matplotlib.figure,当我尝试在图形上使用 .grid() 时它不起作用,或者我缺乏知道如何操作的知识
标签: python matplotlib canvas tkinter grid