【发布时间】:2017-07-18 01:07:40
【问题描述】:
我有这个数据集,其中的列是跨年份的值,而行的值是英镑:
total_2013 total2014 total_2015 total_2016
0 1569000 1614000 1644000 1659000
1 330000 423000 474000 540000
2 2100000 2080000 2093000 2135000
3 2161000 2238000 2221000 2200000
4 1865000 1975000 2046000 2152000
5 1903000 1972000 1970000 2034000
6 2087000 2091000 1963000 1956000
7 1237000 1231000 1199000 1188000
8 1043000 1072000 1076000 1059000
9 569000 610000 564000 592000
10 2207000 2287000 2191000 2274000
11 1908000 1908000 1917000 1908000
我需要在 X 轴上绘制 total_2013、total_2014、total_2015、total_2016 列。
在 Y 轴上,我需要为每一行的单个值画一个点,并在 2013-2016 年的这些值之间画一条线。
我无法通过xticks 将列中的值作为 X 轴上的不同时间点。不确定这是否是正确的做法。
到目前为止,我已经绘制了这个:
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
matplotlib.style.use('ggplot')
ax = data_merged_years.plot(kind='line', title ="UK Schools budget per year 2013-2016", figsize=(15, 10), legend=True, fontsize=12)
ax.set_xlabel("Year", fontsize=12)
ax.set_ylabel("Pounds", fontsize=12)
plt.show()
我的尝试:X 和 Y 不正确的绘图:
【问题讨论】:
-
我不确定我是否理解您的数据集。行的内容是什么?据我所知,一维太多了。
标签: python-2.7 pandas matplotlib plot