У меня есть следующий код:
population = pd.DataFrame(data = population)
fig, ax = plt.subplots(figsize = (10, 5))
population.columns = ['pop']
# ax.area(population['pop'], kind ='area')
# ax = population.plot.area()
ax.fill_between: ax.fill_between(population.index, population['pop'], alpha=0.3, label='Population')
ax.xaxis.set_major_locator(md.YearLocator())
ax.xaxis.set_major_formatter(md.DateFormatter('%Y'))
plt.setp(ax.xaxis.get_majorticklabels(), rotation = 90)
ax.set_xlim([population.index[0], population.index[-1]])
ax.fill_between(population['pop'],0)
Это дает следующий график:
How can i plot an area plot. If i do this:
ax.plot(population['pop'], kind ='area')
I get the following error:
AttributeError: 'Line2D' object has no property 'kind'
If i do this:
ax = population.plot.area()
It leaves the entire formatting on the x-axis. How can i plot area?
Edit:
I get the following plot
For legend:
I added the following line:
ax.fill_between: ax.fill_between(population.index, population['pop'], alpha=0.3, label='Population')
введите описание изображения здесь
Как видите, легенды нет