博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用matplotlib绘制收入增长模型——线性积累型与指数复利型
阅读量:7244 次
发布时间:2019-06-29

本文共 2102 字,大约阅读时间需要 7 分钟。

 一、启发:

  • 关乎增长的事情,即使1%也很重要
  • 复利增长具有恐怖的能量和速度
  • 时间可以创造天壤之别的多样性
  • 一年可以很短,短到从年头看到年尾;一年可以很长,长到完全看不到尽头什么样

 

二、单图版代码:

 

# -*- coding:utf-8 -*-#import matplotlibimport matplotlib.pyplot as pltimport numpy as npimport matplotlib.gridspec as gridspecfrom matplotlib.collections import LineCollectionfrom matplotlib.font_manager import *myfont = FontProperties(fname='/Library/Fonts/simhei.ttf')def showWithParam(ax, total_init, time):		ipd_salary = 0.1#income per day工资每日收入(万元)每月三万	income_salary = loadYSalary(ipd_salary, total_init, time)	ax.plot(time, income_salary,"r-", label="linear incr")	ipd_stock_0 = 0.01#income per day股市每日收入比率	ipd_stock_1 = 0.02#income per day股市每日收入比率	ipd_stock_2 = 0.05#income per day股市每日收入比率	income_stock_0 = loadYStock(total_init, ipd_stock_0, time)	income_stock_1 = loadYStock(total_init, ipd_stock_1, time)	income_stock_2 = loadYStock(total_init, ipd_stock_2, time)	ax.plot(time, income_stock_0, 'y', label="+0.01 rate")	ax.plot(time, income_stock_1, 'b', label="+0.02 rate")	ax.plot(time, income_stock_2, 'g', label="+0.05 rate")	ax.grid(True)	leg = ax.legend(loc="lower right",shadow=True, fancybox=True, title="{0}W Base vs {1}W Incre".format(total_init, 3))	leg.get_title().set_color("red")def loadYSalary(ipd_salary, total_init, days):	income_salary = total_init	income_salary += days * ipd_salary	return income_salarydef loadYStock(total_init, rate, days):	income_stock = total_init	income_stock = income_stock * pow(1 + rate, time)	return income_stockfig, ax = plt.subplots()times = np.arange(0.0, 365)ax.set_xlabel(u'Times(天、次、轮)', fontproperties=myfont, fontsize=25)ax.set_ylabel(u'Total(万元)', fontproperties=myfont, fontsize=25)ax.set_ylim(0, 100)ax.set_title(u'线性累积型与指数复利型增长模型(启动资金3万 VS 每月工资3万)', fontproperties=myfont, fontsize=30, color='black')showWithParam(ax, 3, times)fig.text(0.61, 0.60, u'Result = Base + Incre * Times\n\nResult = Base * (1+Rate)^Times', fontproperties=myfont, color='black', 	ha='right', va='bottom', alpha=0.8, fontsize=15)fig.text(0.55, 0.15, u'by 草莽匠人', fontproperties=myfont, color='black', 	ha='right', va='bottom', alpha=0.5, fontsize=20)plt.show()

  

转载地址:http://baybm.baihongyu.com/

你可能感兴趣的文章
论go语言中goroutine的使用
查看>>
解决td标签上的position:relative属性在各浏览器中的兼容性问题
查看>>
H5图片上传插件
查看>>
iOS5问题汇总
查看>>
[译]Chipmunk教程 - 3 初始化
查看>>
也谈WebKit、Gecko使用图形库
查看>>
6个寓言故事
查看>>
android用sharepreference保存输入框中的内容
查看>>
C# 鼠标穿透窗体功能
查看>>
Windows平台上C++开发内存泄漏检查方法
查看>>
hbase 0.96 java 示例
查看>>
XML与Web Service基础知识点
查看>>
visual studio使用技巧
查看>>
C#几个经常犯错误汇总
查看>>
jQuery data(key, value)函数 在匹配的元素上随心所欲的存放数据 (2
查看>>
经典排序之 冒泡排序
查看>>
PHP 定义栈结构,实现min函数,获取栈最小元素,要求时间复杂度为O(1)
查看>>
ASP.NET 面试题大全
查看>>
设置 xcode 使用arc
查看>>
poj 3026 (最小生成树)
查看>>