本文整理匯總了Python中Plotter.Plotter.updateTanPlot方法的典型用法代碼示例。如果您正苦於以下問題:Python Plotter.updateTanPlot方法的具體用法?Python Plotter.updateTanPlot怎麽用?Python Plotter.updateTanPlot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Plotter.Plotter
的用法示例。
在下文中一共展示了Plotter.updateTanPlot方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: InteractiveEPF
# 需要導入模塊: from Plotter import Plotter [as 別名]
# 或者: from Plotter.Plotter import updateTanPlot [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()