我寫下面的代碼來可視化一個joyplot。當試圖改變使用axes.set_xticks
x軸的標籤,我得到AttributeError: 'list' object has no attribute 'set_xticks'
設置joyplot的x軸標籤
import joypy
import pandas as pd
from matplotlib import pyplot as plt
data = pd.DataFrame.from_records([['twitter', 1],
['twitter', 6],
['wikipedia', 1],
['wikipedia', 3],
['indymedia', 1],
['indymedia', 9]], columns=['platform','day'])
# Get number of days in the dataset
numdays = max(set(data['day'].tolist()))
# Generate date strings from a manually set start date
start_date = "2010-01-01"
dates = pd.date_range(start_date, periods=numdays)
dates = [str(date)[:-9] for date in dates]
fig, axes = joypy.joyplot(data,by="platform")
axes.set_xticks(range(numdays)); axes.set_xticklabels(dates)
plt.show()
預期的輸出應該類似於以下但從dates
日期爲ticklabels。
感謝。我得到'AttributeError:'list'object has no attribute'set_xticks'' – textnet
@ImportanceOfBeingErnest對不起。我現在編輯了原始文章,以便它是完整的,可驗證的,並且希望最小化。 – textnet