如果我使用具有多个头的数据帧的pd.DataFrame.hist()
函数,那么python将绘制多个直方图。你知道吗
我想用plt.axvline
函数和数据帧的平均值来绘制平均值。这不管用
我已经用一个数据帧的一个头试过了,而且成功了。你知道吗
def plot_HistOfDailyReturn(p_df, p_bins=10):
"""plots the histogram of the daily returns"""
df1 = pd.DataFrame(p_df['HCP'])
df1.hist(bins=p_bins)
plt.axvline(df1['HCP'].mean(), color='w', linestyle='dashed', linewidth=2)
plt.show()
我现在如何将此应用于多个?但我不想让他们各自在一个单独的情节里。你知道吗
DataFrame.hist()返回其中的
matplotlib.AxesSubplot
或numpy.ndarray
。如果您有多个列,那么它很可能返回一个numpy.ndarray
的2Dmatplotlib.AxesSubplot
。可以使用这些AxesSubplot在每个子图中绘制线。你知道吗演示:
相关问题 更多 >
编程相关推荐