2016-08-23 4 views

答えて

1

いくつかの目盛りに空の目盛りラベルを設定します。

# based on http://matplotlib.org/examples/ticks_and_spines/ticklabels_demo_rotation.html 
import matplotlib.pyplot as plt 
x = [1, 2, 3, 4] 
y = [1, 4, 9, 6] 
labels = ['Frogs', 'Hogs', '', 'Slogs'] 

plt.plot(x, y, 'ro') 
# You can specify a rotation for the tick labels in degrees or with keywords. 
plt.xticks(x, labels, rotation='vertical') 
# Pad margins so that markers don't get clipped by the axes 
plt.margins(0.2) 
# Tweak spacing to prevent clipping of tick-labels 
plt.subplots_adjust(bottom=0.15) 
plt.show() 

enter image description here

+0

Cool!ほぼそこに!だから、たくさんのデータを使ってこれらのラベルをどのように定義すればいいですか?たとえば、x = np.arange(0,100,1)の場合、ラベルを10,20などにしたいのですか?私はlables = np.arange(0,100,10)を試しましたが、うまくいきませんでした...ありがとう – durbachit

+0

これを回避する方法を考えました。分裂のifループによって簡単に! – durbachit

1

だけセレニティの答えに私のコメントに答えるために、ここでの数値ラベルを取得する方法です。

x = range(100) 
labels = [] 
for i in x: 
    if i % 10 == 0: 
     i=i 
    else: 
     i=' ' 
    labels.append(i) 

これは機能します。

関連する問題