Matplotlib Pyplot简单意大利面p

2024-10-02 00:25:07 发布

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

我试图写一个简单的Python3 Matplotlib pyplot only(没有numpy或pandas)定义到一个spaghettiplot3列表的同一个轴上。 现在绘图工作,但有3个单独的分区范围吗? 数据是一个简单的10点基于时间的增量,所以我跳过了xaxis列表。在

____ Ain0____ Ain1___ Ain2

0 : 4.9072    1.4307    0.0000     
1 : 4.9072    1.4307    0.0000     
2 : 4.9072    1.4307    0.0000     
3 : 4.9072    1.4307    0.0000     
4 : 4.9072    1.4307    -0.0098     
5 : 4.9072    1.4404    0.0000     
6 : 4.9072    1.4307    0.0049     
7 : 4.9072    1.4307    0.0000     
8 : 4.9072    1.4307    -0.0049     
9 : 4.9072    1.4307    0.0000

y轴限制应为+/-5。在

^{pr2}$

我的情节是这样的:

enter image description here


Tags: 数据numpy绘图onlypandas列表定义matplotlib
1条回答
网友
1楼 · 发布于 2024-10-02 00:25:07

首先,应在绘图后设置绘图的用户定义轴限制,否则绘图前的设置值将被覆盖。在

话虽如此,我不确定以下是不是你要找的。我只是改变了绘制和定义轴极限的顺序。另外,还有两行多余的代码用于设置y限制。在

import matplotlib.pyplot as plt

def Matplot():
    global DIFF_USED, DataSize, Data_Ain0,Data_Ain1,Data_Ain2,Data_Ain3
    plt.plot(Data_Ain0, 'r ', label='Ain0')
    plt.plot(Data_Ain1, 'bs', label='Ain1')
    plt.plot(Data_Ain2, 'g^', label='Ain2')

    plt.xlabel('time')
    plt.ylabel('Volts')
    plt.axis([0, DataSize, -5, 5]) 
    plt.show()

enter image description here

相关问题 更多 >

    热门问题