如何用直方图绘制连续值的混合图?

问题描述 投票:2回答:1

我想制作一个连续值的混合图,如AgeFare,用直方图绘制。

到目前为止,我有一个没有所需连续线的直方图:

data['Fare'].iplot(kind='hist', xTitle='count',
                  yTitle='money', title='Fare Distribution')

我想得到这样的结果:

enter image description here

帮助将不胜感激。谢谢。

python matplotlib plotly seaborn
1个回答
0
投票

既然你说AgeFare,你会发现你正在为一个变量寻找一个连续的分布图和相应的直方图。如果是这种情况,下面的代码片段应该使用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)

情节:

enter image description here

我希望这就是你要找的东西。如果没有,请不要犹豫,告诉我!

© www.soinside.com 2019 - 2024. All rights reserved.