【发布时间】:2018-04-24 15:11:36
【问题描述】:
总结重要的一点:
我有一个函数可以在 matplotlib 图形上绘制一个圆圈。每次我回想这个函数时,我都会简单地调整圆的大小(使用 set_radius),因为它总是需要在图表上的相同位置(在中心)。这样就不会太乱了
我想用椭圆补丁做同样的事情,但这次可以改变它的高度、宽度和角度。但是我找不到任何等效的 set_radius
def Moment_Of_Inertia(self):
"""Plot the moment of Inertia ellipse, with the ratio factor """
# my code to get ellipse/circle properties
self.limitradius = findSBradius(self.RawImage,self.SBLimit)[0]
MoIcall = mOinertia(self.RawImage,self.limitradius)
self.ratio=MoIcall[0] # get the axes ratio
self.height=1
Eigenvector = MoIcall[1]
self.EllipseAngle np.degrees(np.arctanh((Eigenvector[1]/Eigenvector[0])))
# This is the part I am not sure how to do
self.MoIellipse.set(width=self.ratio*15)
self.MoIellipse.set(height=self.height*15)
self.MoIellipse.set(angle= self.EllipseAngle)
# It works with a circle patch
self.circleLimit.set_radius(self.limitradius)
self.circleLimit.set_visible(True)
self.MoIellipse.set_visible(True)
self.canvas.draw()
如果我的代码有点脱离上下文,我很乐意解释更多,我正在尝试在 tkinter 窗口中嵌入一个 matplotlib 图。两个补丁都已经在构造函数中初始化了,我只想调整它们的大小。
【问题讨论】:
-
什么是
.MoIellipse?请阅读并理解minimal reproducible example。 -
这是我已经在构造函数中初始化的补丁的名称
标签: python matplotlib tkinter ellipse