总结一下要点:
我有一个函数,在matplotlib图上画一个圆。每次我回忆起这个函数时,我只需调整圆的大小(使用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图形。两个补丁都已经在构造函数中初始化了,我只想调整它们的大小。在
这个答案假设问题是关于^{} 中的椭圆。在
它有属性
width
、height
和angle
。可以将这些属性设置为对于任何其他python对象,也可以使用
^{pr2}$setattr
,比如一些完整的例子:
相关问题 更多 >
编程相关推荐