[英]How to modify the group spacing of X axis in Seaborn distplot
這里輸入圖片描述我畫了一個頻率分布直方圖,但是不知道怎么修改它的組間距有沒有辦法把X軸的0-100改成0-50、50-100等等我想要有這樣的坐標軸
def norm_comparision_plot(data,title, figsize=(14,6), color="#099DD9",ax=None, surround=True, grid=True):
plt.figure(figsize=figsize)
sns.distplot(data,hist=True,fit=norm,color=color,kde_kws={"color": color, "lw": 3}, ax=ax)
(mu, sigma) = norm.fit(data)
set(xlim=(0,30),ylim=(0,100)))
plt.legend([title+'', ' ($\mu=$ {:.2f} and $\sigma=$ {:.2f} )'.format(mu, sigma)], loc='best')
plt.ylabel('')
plt.title(title+"")
if surround == True:
sns.despine(trim=True, left=True, offset=10)
if grid == True:
plt.grid(True)
plt.show()
你還沒有發布足夠多的代碼,所以我不確定我在這里能有多准確,但我猜在你的代碼中的某個時刻你正在調用plt.subplot
__, ax = plt.subplots(......)
在這種情況下,您需要添加以下行:
ax.set(xlim=(0, 100))
將您的圖表限制在 0 到 100 之間
希望我能幫上忙,如果您需要任何澄清,請在此處發表評論,我會為您提供幫助
如果此評論對您有所幫助,請考慮將其標記為答案:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.