Python 如何在plotly中使用直方图混合绘制连续值?
我想用plotly中的直方图绘制一个连续值的混合图,如Python 如何在plotly中使用直方图混合绘制连续值?,python,matplotlib,plotly,seaborn,Python,Matplotlib,Plotly,Seaborn,我想用plotly中的直方图绘制一个连续值的混合图,如Age或Fare 我得到了一个直方图,但没有所需的连续线: data['Fare'].iplot(kind='hist', xTitle='count', yTitle='money', title='Fare Distribution') 我希望得到这样的结果: 我们将不胜感激。谢谢。既然你说的是年龄或票价,听起来你在寻找一个变量的连续分布图和相应的直方图。如果是这样的话,下面的代码片段应该使用Jup
Age
或Fare
我得到了一个直方图,但没有所需的连续线:
data['Fare'].iplot(kind='hist', xTitle='count',
yTitle='money', title='Fare Distribution')
我希望得到这样的结果:
我们将不胜感激。谢谢。既然你说的是
年龄
或票价
,听起来你在寻找一个变量的连续分布图和相应的直方图。如果是这样的话,下面的代码片段应该使用Jupyter笔记本来实现这一点:
片段:
#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)
绘图:
#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)
我希望这就是你想要的。
如果没有,请毫不犹豫地告诉我