Pandas 如何获得水平方向的kde密度?

Pandas 如何获得水平方向的kde密度?,pandas,matplotlib,orientation,histogram,seaborn,Pandas,Matplotlib,Orientation,Histogram,Seaborn,熊猫在绘图时提供kind='kde'。在我的设置中,我更喜欢kde密度。另一种类型的class='histogram'提供了方向选项:orientation='horizontal',这对于我所做的工作来说是绝对必要的。不幸的是,方向是从柱状图中重新编辑的,到目前为止kde不可用 至少我认为这是因为我得到了一个 in set_lineprops raise TypeError('There is no line property "%s"' % key) TypeError: There

熊猫在绘图时提供kind='kde'。在我的设置中,我更喜欢kde密度。另一种类型的class='histogram'提供了方向选项:orientation='horizontal',这对于我所做的工作来说是绝对必要的。不幸的是,方向是从柱状图中重新编辑的,到目前为止kde不可用

至少我认为这是因为我得到了一个

in set_lineprops
    raise TypeError('There is no line property "%s"' % key)
TypeError: There is no line property "orientation"
是否有任何直接的替代方法可以像绘制直方图一样轻松地水平绘制kde


你可能想用seaborn来回答这个问题:@Paul H你能把它作为一个答案发布吗(我测试过了,效果很好)?我认为你的建议比ayhan的答案更直截了当(如果完全有效的话)。
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

plt.ion()

ser = pd.Series(np.random.random(1000))
ax1 = plt.subplot(2,2,1)
ser.plot(ax = ax1, kind = 'hist')
ax2 = plt.subplot(2,2,2)
ser.plot(ax = ax2, kind = 'kde')
ax3 = plt.subplot(2,2,3)
ser.plot(ax = ax3, kind = 'hist', orientation = 'horizontal')

# not working lines below
ax4 = plt.subplot(2,2,4)
ser.plot(ax = ax4, kind = 'kde', orientation = 'horizontal')