我正在尝试使用matplotlib在Python中创建一个非线性x轴,但没有找到任何函数或解决此问题的方法
这就是我们的graph在这个时间点上的样子,我想把它转换成类似this.的东西(看看两个图的x轴上的差异)
到目前为止,我拥有的代码是:
plt.axis([0, 100, 0, 1])
plt.plot(onecsma_x, onecsma_y, label='1-CSMA')
plt.plot(slotted_aloha_x,slotted_aloha_y, label ='Slotted Aloha')
plt.plot(pure_aloha_x,pure_aloha_y, label ='Pure Aloha')
plt.plot(npcsma_x, npcsma_y, label ='Non persisten CSMA')
plt.plot(pcsma_x, pcsma_y, label ='P persistent CSMA')
plt.legend(loc='upper right')
plt.show()
对于日志x轴,使用
semilogx
而不是plot
此外,您还可以在使用
semilogx
之后(但在show
之前)限制x轴:相关问题 更多 >
编程相关推荐