简体   繁体   中英

Align y-axes of horizontal histogram with series plot in subplots side-by-side

I have a line plot (see below).

I would like to add a subplot showing a histogram of the same values that is oriented to the right, such that the y-axis of the line plot matches the value-axis of the histogram.

Any suggestions?

dfB2.plot(x='Date', y='Norm')  
plt.axhline(y = y.mean(), color = 'red', linestyle = '--', linewidth = 1)  
plt.axhspan(1, (-1), color='red', alpha=0.10,)

在此处输入图像描述

Create the subplots with plt.subplots() and set sharey=True .

In order to make the df.plot() and df.hist() calls use your subplots, you can pass in the corresponding axes object via the ax keyword argument.

For reference:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM