2

ここに画像の説明を入力してください

私はこのようなグラフを持っています、それは21日間の毎時のデータを記録します、ラベルは次のようです:01-30 00:00、01-30 01:00 ....今は読めないので、1つだけ設定したい1日あたりのラベルなので、毎日の最初のラベルのみを表示します:01-30 00:00、01-31 00:00など

私のコードは:

fig1 = plt.figure()  
ax = fig1.add_subplot(111)
ind = np.arange(len(timelist))
ax.bar(ind,reqlist,color='b')
ax.set_xlim((0,len(timelist)))
ax.set_ylabel('Number of request/video',size='x-large')
ax.set_title('Request per hour North',size='xx-large')
ax.set_xticks(ind)
ax.set_xticklabels(timelist,rotation=17)

タイムリストは文字列のリストです:["01-30 00:00"、 "01-30 00:01" .....]

4

1 に答える 1

1

必要なラベルだけを付けて、残りは空の文字列にすることができます。
たとえば、24 (1 日) ごとにラベルのみが必要な場合:

newlist = []
for index, item in enumerate(timelist):
    if index % 24 == 0:
        newlist.append(item)
    else:
        newlist.append('')
ax.set_xticklabels(newlist, rotation=17)
于 2012-08-20T16:43:20.910 に答える