小编ay-*_*ron的帖子

pyplot x轴正在排序

这是在一台Windows 7 x64位机器上,在PyCharm教育版1.0.1编译器中运行python 3.4.3 x64位.用于此计划的数据来自纽约市的Citi Bike计划(数据见http://www.citibikenyc.com/system-data).

我已对数据进行了排序,以便我有一个新的CSV文件,其中包含uniqe自行车ID以及每个自行车骑行的次数(文件名为Sorted_Bike_Uses.csv).我试图用自行车ID和使用次数制作一个图表(X轴上的自行车ID,y轴上的使用次数).我的代码看起来像这样:

import pandas as pd
import matplotlib.pyplot as plt

# read in the file and separate it into two lists
a = pd.read_csv('Sorted_Bike_Uses.csv', header=0)
b = a['Bike ID']
c = a['Number of Uses']

# create the graph
plt.plot(b, c)

# label the x and y axes
plt.xlabel('Bicycles', weight='bold', size='large')
plt.ylabel('Number of Rides', weight='bold', size='large')

# format the x and y ticks
plt.xticks(rotation=50, horizontalalignment='right', weight='bold', size='large')
plt.yticks(weight='bold', size='large')

# give it a title …
Run Code Online (Sandbox Code Playgroud)

python csv matplotlib python-3.x

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

csv ×1

matplotlib ×1

python ×1

python-3.x ×1