本文整理汇总了Python中Plotter.Plotter.updateTanChart方法的典型用法代码示例。如果您正苦于以下问题:Python Plotter.updateTanChart方法的具体用法?Python Plotter.updateTanChart怎么用?Python Plotter.updateTanChart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plotter.Plotter
的用法示例。
在下文中一共展示了Plotter.updateTanChart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: InteractiveEPF
# 需要导入模块: from Plotter import Plotter [as 别名]
# 或者: from Plotter.Plotter import updateTanChart [as 别名]
class InteractiveEPF():
def __init__(self, parent):
'''
Constructor
'''
self.parent = parent
self.portfolioManager = PortfolioManager()
self.plotter = Plotter(parent)
def initUI(self, expReturn=.0100):
self.portfolioManager.initEPF()
self.portfolioManager.runEPF(expReturn=expReturn)
self.plotter.initRanges(self.portfolioManager.portfolios, self.portfolioManager.companies)
self.plotter.initPlot(self.portfolioManager.portfolios, self.portfolioManager.companies)
self.plotter.initChart(self.portfolioManager.portfolios, self.portfolioManager.companies)
#self.plotter.pack()
axcolor = 'white'
axRet = pyplot.axes([0.25, 0.032, 0.65, 0.02], axisbg=axcolor)
self.sRet = Slider(axRet, 'Expected Return', 0.0, self.plotter.ymax, valinit=expReturn, valfmt='%1.4f')
self.sRet.on_changed(self.expReturnChange)
axRet = pyplot.axes([0.25, 0.008, 0.65, 0.02], axisbg=axcolor)
self.tRet = Slider(axRet, 'Risk-Free Return', 0.0, self.plotter.ymax, valinit=0.0, valfmt='%1.4f')
self.tRet.on_changed(self.tanChange)
def addPortfolio(self, portfolio):
self.portfolioManager.addPortfolio(portfolio)
def expReturnChange(self, expRet):
expRet = self.sRet.val
tanRet = self.tRet.val
self.portfolioManager.runEPF(expReturn=float(expRet), freeReturn=float(tanRet))
self.plotter.updateExpRetPlot(self.portfolioManager.portfolios)
self.plotter.updateExpRetChart(self.portfolioManager.portfolios)
def tanChange(self, expRet):
expRet = self.sRet.val
tanRet = self.tRet.val
self.portfolioManager.runEPF(expReturn=float(expRet), freeReturn=float(tanRet))
self.plotter.updateTanPlot(self.portfolioManager.portfolios)
self.plotter.updateTanChart(self.portfolioManager.portfolios)
def show(self):
pyplot.show()