matplotlib中非统一(非线性)xaxis的Python实现

2024-10-03 13:16:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用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()

Tags: 方法函数plotmatplotlibpurepltlabelgraph