【发布时间】:2020-12-09 09:48:13
【问题描述】:
我正在尝试将轨道模拟嵌入到 tkinter 框架中,我的绘图工作正常我现在只是尝试在图中输入圆圈来表示行星。我查看了有关如何在 FigureCanvasTkAgg 中绘制圆圈的文档,但找不到任何内容,希望有人能提供帮助。
代码如下:
matplotlib.use('TkAgg')
root = Tk.Tk()
root.wm_title("Orbital Simulation")
fig = plt.Figure()
canvas = FigureCanvasTkAgg(fig, root)
canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
ax=fig.add_subplot(111)
fig.subplots_adjust(bottom=0.25)
gridArea = [0, 200, 0, 200] # margins of the coordinate grid
ax.axis(gridArea) # create new coordinate grid
ax.grid(b="on") # place grid
.
.
.
def placeObject(self):
drawObject = ax.Circle(self.position, radius=self.radius, fill=False, color="black")
ax.gca().add_patch(drawObject)
ax.show()
错误:
drawObject = ax.Circle(self.position, radius=self.radius, fill=False, color="black") AttributeError: 'AxesSubplot' 对象没有属性 'Circle'
非常感谢任何帮助。
【问题讨论】:
-
请也发布完整的错误代码。
-
有完整的错误码
标签: python matplotlib tkinter