月份 | 私家车 | 旅游巴士 | 穿梭巴士 | 货车及货柜车 | 车辆总数 | 按月总增长 |
---|---|---|---|---|---|---|
2018年10月 | 5,754 (32.56%) | 2,338 (13.23%) | 9,288 (52.56%) | 290 (1.64%) | 17,670 | |
2018年11月 | 32,597 (31.22%) | 24,588 (23.55%) | 43,871 (42.01%) | 3,371 (3.34%) | 104,427 | |
2018年12月 | 45,073 (37.88%) | 23,142 (19.45%) | 45,485 (38.22%) | 5,302 (4.46%) | 119,002 | ▲14.0% |
2019年1月 | 44,863 (42.46%) | 16,803 (15.90%) | 36,981 (35.00%) | 7,020 (6.64%) | 105,667 | ▼11.2% |
2019年2月 | 55,117 (48.03%) | 17,435 (15.19%) | 38,763 (33.78%) | 3,429 (2.99%) | 114,744 | ▲8.6% |
2019年3月 | 60,954 (47.31%) | 16,200 (12.57%) | 43,272 (33.59%) | 8,407 (6.53%) | 128,833 | ▲12.3% |
2019年4月 | 68,921 (48.44%) | 17,515 (12.31%) | 48,026 (33.75%) | 7,831 (5.5%) | 142,293 | ▲10.4% |
2019年5月 | 79,217 (53.33%) | 15,562 (10.48%) | 46,355 (31.21%) | 7,421 (4.99%) | 148,546 | ▲4.4% |
2019年6月 | 72,448 (53.34%) | 14,580 (10.74%) | 41,423 (30.50%) | 7,362 (5.42%) | 135,813 | ▼8.6% |
2019年7月 | 75,220 (53.30%) | 14,426 (10.22%) | 43,213 (30.62%) | 8,271 (5.86%) | 141,130 | ▲3.9% |
2019年8月 | 72,701 (54.98%) | 14,609 (11.05%) | 36,844 (27.86%) | 8,081 (6.11%) | 132,235 | ▼6.3% |
2019年9月 | 65,838 (58.83%) | 12,014 (10.73%) | 26,149 (23.36%) | 7,918 (7.07%) | 111,919 | ▼15.4% |
2019年10月 | 78,290 (63.49%) | 10,855 (8.80%) | 26,426 (21.43%) | 7,740 (6.28%) | 123,311 | ▲10.2% |
2019年11月 | 71,447 (63.97%) | 9,505 (8.51%) | 23,081 (20.67%) | 7,648 (6.85%) | 111,681 | ▼9.4% |
2019年12月 | 77,530 (62.05%) | 12,565 (10.06%) | 26,787 (21.44%) | 8,060 (6.45%) | 124,942 | ▲11.9% |
2020年1月 | 72,441 (63.78%) | 12,396 (10.91%) | 21,850 (19.24%) | 6,897 (6.07%) | 113,584 | ▼9.1% |
2020年2月 | 25,152 (61.67%) | 3,260 (7.99%) | 7,098 (17.40%) | 5,278 (12.94%) | 40,788 | ▼64.1% |
2020年3月 | 26,123 (55.76%) | 2,582 (5.51%) | 9,522 (20.33%) | 8,618 (18.40%) | 46,845 | ▲14.8% |
2020年4月 | 313 (3.65%) | 90 (1.05%) | 678 (7.90%) | 7,497 (87.40%) | 8,578 | ▼81.7% |
2020年5月 | 289 (3.26%) | 94 (1.06%) | 700 (7.90%) | 7,773 (87.77%) | 8,856 | ▲3.2% |
2020年6月 | 320 (3.09%) | 23 (0.22%) | 779 (7.53%) | 9,230 (89.16%) | 10,352 | ▲16.9% |
2020年7月 | 525 (4.86%) | 4 (0.04%) | 947 (8.76%) | 9,336 (86.35%) | 10,812 | ▲4.4% |
import re
import pandas as pd
from matplotlib import pyplot as plt
dataPath = './test.txt'
dataframe = pd.read_csv(dataPath, sep="\t")
def Process(df:pd.DataFrame, name:str):
reler = re.compile(r"\d.* ")
for i in range(df.shape[0]):
data = df[name][i]
search = reler.search(data)
s, e = search.start(), search.end()
df[name][i]= data[s:e].replace(',',"")
Process(dataframe, '私家车')
Process(dataframe, '旅游巴士')
Process(dataframe, '穿梭巴士')
Process(dataframe, '货车及货柜车')
dataframe
dataframe['私家车'] = dataframe['私家车'].astype('int')
dataframe['旅游巴士'] = dataframe['旅游巴士'].astype('int')
dataframe['穿梭巴士'] = dataframe['穿梭巴士'].astype('int')
dataframe['货车及货柜车'] = dataframe['货车及货柜车'].astype('int')
dataframe.set_index('月份', inplace=True)
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签
dataframe.plot(xlabel = '港珠澳大桥香港口岸使用量', )
plt.grid()
plt.show()
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
x = np.linspace(-1*np.pi, np.pi, 100)
y = np.sin(x)
y1 = np.cos(x)
plt.plot(x, y, linestyle = '--')
plt.plot(x, y1, linestyle = '-.')
plt.show()
linestyle取值可为'-', '--', '-.', ':', 'None', ' ', '', 'solid', 'dashed', 'dashdot', 'dotted'
plt.plot(x, y, linestyle = '--' , label = '--')
plt.plot(x, y1, linestyle = '-.', label = '-.')
plt.legend()
加上plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签
即可
plt.axis([0,16, 0, 150])
分别为[xstart, xend, ystart, yend]
比如上述坐标,我想将其范围改为-100-100
那么使用在计算的时候用x,但是绘图的时候用x1即可
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
x = np.linspace(-1*np.pi, np.pi, 100)
y = np.sin(x)
y1 = np.cos(x)
x1 = np.linspace(-100, 100, 100)
# x2 = [str(m).split('.')[0] for m in x1 ]
plt.plot(x1, y, linestyle = '--' , label = '--')
plt.plot(x1, y1, linestyle = '-.', label = '-.')
# plt.xticks(x2)
plt.legend()
plt.show()