2017-09-27 15 views
0

積み上げ棒グラフをプロットしようとしています。しかし、私は棒の間隔を減らすことができません。私は、バーを狭くしたいが、バーの間にスペースを入れないか、またはスペースをあまり小さくしたい。あなたが見るべきであることはleftパラメータです積み重なった棒グラフの棒間の間隔を減らす方法は?

bar(left, height, width=0.8, bottom=None, hold=None, data=None, **kwargs) 

私は、次のコードを使用しています:以下のように

#!/usr/bin/env python3 
# -*- coding: utf-8 -*- 
""" 
Created on Mon Aug 21 16:56:27 2017 

@author: Sayali 
""" 
import seaborn 
import matplotlib.pyplot as plt 
MA1D = [52.18507078,52.18227723,44.02015981] 
MA1S = [47.81492922,47.81772277,55.97984019] 
MA1E = [3.32543281,1.563038488,7.179669498] 
figure = plt.figure() 
figure.text(0.5, 0.04,'Days' , ha='center') 
figure.text(0.02, 0.5, 'Amount of time (Percentage)', va='center', 
rotation='vertical') 
plt.subplot(3, 1, 1) 
plt.grid(zorder=0,which='major', axis='y', color='silver', ls='dotted' 
) 
plt.bar(range(len(MA1D)), MA1D, color='salmon',width=0.1, 
align='center', zorder=2, yerr=MA1E, error_kw=dict(ecolor='red', lw=2, 
capsize=3, capthick=1,zorder=5)) 
plt.bar(range(len(MA1S)), MA1S, bottom=MA1D, 
color='whitesmoke',width=0.1, align='center', zorder=2) 
plt.box(on=None) 
plt.yticks([0,50,100]) 
plt.subplots_adjust(left=0.075, right=0.9, top=0.9, bottom=0.1) 
plt.subplot(3, 1, 2) 
plt.bar(range(len(MA1D)), MA1D) 
plt.bar(range(len(MA1S)), MA1S, bottom=MA1D) 
plt.box(on=None) 
plt.subplot(3, 1, 3) 
plt.bar(range(len(MA1D)), MA1D) 
plt.bar(range(len(MA1S)), MA1S, bottom=MA1D, 
color='whitesmoke',width=0.1, align='center', zorder=2) 

plt.subplots_adjust(wspace=0.07, hspace=0.05) 
plt.show() 

答えて

0

機能バーを()さんのparamsは同じです。これは各バーの開始点を表します。

あなたのコードで

range(len(MA1D)) 
# this would be [0,1,2] 

ので、幅を小さくするために、あなたはちょうどあなたがパラメータwidthに注意する必要があります。この場合、

[0.3,0.5,0.7] 

以下のようなものを作成する必要があります。ご覧のとおり、widthのデフォルト値は0.8です

私はあなた自身でそれを調整することができると信じています。

関連する問題