multiple= 参数似乎与hue= 参数一起使用。为此,应将数据框转换为long form:
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
df_sz = pd.DataFrame({'Ann1': (2 ** np.random.uniform(1, 20, 200)).astype(int),
'Ann2': (2 ** np.random.uniform(1, 20, 200)).astype(int),
'Ann3': (2 ** np.random.uniform(1, 20, 200)).astype(int),
'Ann4': (2 ** np.random.uniform(1, 20, 200)).astype(int)})
fig, ax = plt.subplots(figsize=(20, 4)) # very wide figure to accomodate 200 bars
sns.histplot(data=df_sz.melt(), x='value', hue='variable', bins=50,
alpha=0.5, shrink=0.8, log_scale=True, multiple='dodge', ax=ax)
ax.legend_.set_title('') # remove the legend title (the name of the hue column)
ax.margins(x=0.01) # less spacing
plt.tight_layout()
plt.show()