【发布时间】:2015-11-25 22:33:13
【问题描述】:
我有一个线性比例的散点图。我想从Marginal Histograms and Box Charts 向我的散点图like this figure 的边距(左侧和底部)添加一个箱线图?
更新 这是我目前的工作解决方案,请分享您的想法或提出更好的建议。
ax.plot(df['vcnt'], df['ecnt'], 'ko', alpha=0.5)
# Save the default tick positions, so we can reset them..
tcksx = ax.get_xticks()
tcksy = ax.get_yticks()
ax.boxplot(df['ecnt'], positions=[min(tcksx)], notch=True, widths=1.)
ax.boxplot(df['vcnt'], positions=[min(tcksy)], vert=False, notch=True, widths=1.)
ax.set_yticks(tcksy) # pos = tcksy
ax.set_xticks(tcksx) # pos = tcksx
ax.set_yticklabels([int(j) for j in tcksy])
ax.set_xticklabels([int(j) for j in tcksx])
ax.set_ylim([min(tcksy-1),max(tcksy)])
ax.set_xlim([min(tcksx-1),max(tcksx)])
【问题讨论】:
标签: python matplotlib plot boxplot margins