python : bokeh 画基金净值线

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 np
import pandas as pd
import bokeh.plotting as bp

# dataFrame 
df = pd.read_csv('/python/66001_.txt', parse_dates=['date'])

# Configuring plot output file
bp.output_file("fund_value_1.html", title="Fund net value")

# Create the figure and define some properties
fig = bp.figure(title=u"基金净值图", width=1000,
                x_axis_label='date', y_axis_label='value', x_axis_type="datetime")

# add 6 lines
fig.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

猜你喜欢

转载自blog.csdn.net/belldeep/article/details/78763315