python plotly画柱状图代码实例
人气:0这篇文章主要介绍了python plotly画柱状图代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
代码
import pandas as pd import numpy as np import plotly.plotly as py import plotly.graph_objs as go path = '/home/v-gazh/PycharmProjects/us_data/counts.csv' df = pd.read_csv(path) df['PERMNO'] = df['PERMNO'].map(lambda x : 'P'+str(x) ) # 该了下类型 此行有可无 df.set_index(['PERMNO'], inplace=True) trace1 = go.Bar( x=df.index, y=df['tickerCount'].squeeze(), name='一个P对应TICKER个数' ) trace2 = go.Bar( x=df.index, y=df['exchcdCount'].squeeze(), name='一个P对应EXCHCD个数' ) data = [trace1, trace2] layout = go.Layout( barmode='group'#分组 ) fig = go.Figure(data=data, layout=layout) py.iplot(fig, filename='grouped-bar')
图示
您可能感兴趣的文章:
加载全部内容