|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- print(way1)
- print(way2)
- plt.plot(n, way1, color='blue', label='without priority', linestyle='-')
- plt.plot(n, way2, color='red', label='with priority', linestyle='-')
- plt.legend()
- type1 = {'family': 'Times New Roman', 'weight': 'normal', 'size': 15}
- plt.xlabel('Number of the mobile devices', type1)
- plt.ylabel('Access rate', type1)
- plt.gca().invert_yaxis()
- plt.show()
复制代码
['100%', '100%', '100%', '100%', '100%', '100%', '100%', '100%', '100%', '98%', '95%', '93%', '88%', '86%', '83%', '79%', '79%', '76%', '75%', '73%']
['100%', '100%', '100%', '100%', '100%', '100%', '100%', '100%', '100%', '98%', '96%', '97%', '94%', '91%', '89%', '88%', '87%', '86%', '84%', '84%']
这是way1和way2的数据
求问画出来的图纵坐标中间大是怎么回事?
你的way1, way2 里面是字符串!不是数据!
这样虽然可以画出来,可实际是 y轴用的是 字符标记,不是数据,相当于 分别根据这些标记 画了两条线。
也就是,因为 y轴数据根本没共享,导致各画各的了。
所以,
- from matplotlib import pyplot as plt
- import pandas as pd
- way1 = ['100%', '100%', '100%', '100%', '100%', '100%', '100%', '100%', '100%', '98%', '95%', '93%', '88%', '86%', '83%', '79%', '79%', '76%', '75%', '73%']
- way2 = ['100%', '100%', '100%', '100%', '100%', '100%', '100%', '100%', '100%', '98%', '96%', '97%', '94%', '91%', '89%', '88%', '87%', '86%', '84%', '84%']
- way1 = [int(i[:-1])/100 for i in way1]
- way2 = [int(i[:-1])/100 for i in way2]
- x = range(len(way1))
- plt.plot(x, way1)
- plt.plot(x, way2)
复制代码
|
|