2016-06-25 5 views
0

次は、棒グラフを生成するための私のPythonコードです:、xticksが重なっなっている出力でPythonのmathplotlib - xticks内のテキストを重ねるとyticksにパーセント記号を追加

import matplotlib.pyplot as plt; plt.rcdefaults() 
import numpy as np 
import matplotlib.pyplot as plt 

objects = ('Increasing operational efficiency', 
     'Informing strategic direction', 
     'Better customer service', 
     'Identifying and developing new products', 
     'Enhanced customer experience', 
     'Identifying new markets', 
     'Faster go to market', 
     'Complying with regulations', 
     'Other') 
y_pos = np.arange(len(objects)) 
performance = [51, 36, 27, 24, 20, 11, 8, 6, 3] 

plt.bar(y_pos, performance, align='center', alpha=0.5) 
plt.xticks(y_pos, objects) 

plt.show() 

克服する方法がありますそれ。私の2番目の疑問は、値が0から60までの間隔で10の値をとっているyticksで、0%、10%、...、60%のような数字と一緒に '%'記号を追加する方法がある10、0より、...、60

は、私はあなたが簡単な検索でのご質問を見つけただろう

答えて

1

をmathplotlibに新しいです、助けてくれてありがとう...

ます

01を使用して、y軸上のパーセント記号ため plt.gcf().autofmt_xdate()

を用いて、X軸のラベルを回転させることができます

+0

@Dizietがありがとうございますが、ウィンドウ内に収まるラベルはほとんどありません。ウィンドウを拡張する方法はありますか? – Jeril

+0

ウィンドウを適切なサイズに自動的に展開するには、 'plt.tight_layout()'を使用します。 – Dvg25

関連する問題