python : bokeh 画基金净值线

来源:互联网 发布:智慧城市优化公共服务 编辑:程序博客网 时间:2024/05/17 07:55

python bokeh : 交互式 Web 图表绘制

数据格式同上几篇

date,jz0,jz1,jz2,jz3,jz4,jz5

http://pypi.python.org
Downloading bokeh-0.12.13.tar.gz (15.4MB)

解压 bokeh-0.12.13.tar.gz
setup.py install

会连互联网下载一些依赖包

bokeh_line6.py

# -*- coding: utf-8 -*-import numpy as npimport pandas as pdimport bokeh.plotting as bp# dataFrame df = pd.read_csv('/python/66001_.txt', parse_dates=['date'])# Configuring plot output filebp.output_file("fund_value_1.html", title="Fund net value")# Create the figure and define some propertiesfig = bp.figure(title=u"基金净值图", width=1000,                x_axis_label='date', y_axis_label='value', x_axis_type="datetime")# add 6 linesfig.line(df['date'], df['jz0'], color="black", legend='660010')fig.line(df['date'], df['jz1'], color="blue",  legend='660011')fig.line(df['date'], df['jz2'], color="green", legend='660012')fig.line(df['date'], df['jz3'], color="yellow",legend='660013')fig.line(df['date'], df['jz4'], color="red",   legend='660014')fig.line(df['date'], df['jz5'], color="purple",legend='660015')bp.show(fig)

参考书:[ Python for Finace ]
http://bokeh.pydata.org

原创粉丝点击