-1
誰知道爲什麼我得到這些奇怪的x軸標籤?原始代碼有註釋行,產生了類似的結果,所以我嘗試按字母順序排列列表來檢查導致問題的原因並得到相同的結果。
下面的代碼:
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as mtick
import numpy as np
input_file = 'CSP.csv'
output_file = 'sub_plots.png'
y = []
#susbset to SDs first
df1 = df[(df.Class=='FIR')]
x = np.arange(len(df1.ix[:,0]))
for i in range(8):
y.append(df1.ix[:,i+7])
fig, ax = plt.subplots()
labels=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','aa','ab','ac']
ax.stackplot(x,y[0],y[1],y[2],y[3],y[4],y[5],y[6],y[7])
#labels = [str(i) for i in list(df1.Local_Authority)]
plt.xticks(x,labels,size='small')
ax.set_xticklabels(ax.xaxis.get_majorticklabels(), rotation=90)
fig = plt.gcf()
fig.subplots_adjust(bottom=0.3)
plt.savefig(output_file_1)
謝謝。我覺得我很困惑,因爲每次我想要做一些新的東西如旋轉文本或更改標籤,我谷歌如何做到這一點,但是當我結合所有這些方法,他們不匹配。 – TaxpayersMoney