我想制作一个连续值的混合图,如Age
或Fare
,用直方图绘制。
到目前为止,我有一个没有所需连续线的直方图:
data['Fare'].iplot(kind='hist', xTitle='count',
yTitle='money', title='Fare Distribution')
我想得到这样的结果:
帮助将不胜感激。谢谢。
既然你说Age
或Fare
,你会发现你正在为一个变量寻找一个连续的分布图和相应的直方图。如果是这种情况,下面的代码片段应该使用Jupyter Notebook:
片段:
#imports
import plotly
import cufflinks as cf
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import pandas as pd
import plotly.plotly as py
import plotly.figure_factory as ff
# setup
init_notebook_mode(connected=True)
np.random.seed(123)
cf.set_config_file(theme='pearl')
# qtconsole for debugging
#%qtconsole --style vim
# Random data using cufflinks
df = cf.datagen.lines()
df = df[['FSZ.WH']]
df.columns = ['Fare']
# Make plotly figure
group_labels = ['distplot']
fig = ff.create_distplot([df['Fare']], group_labels)
# Plot figure
iplot(fig)
情节:
我希望这就是你要找的东西。如果没有,请不要犹豫,告诉我!