绘制多索引数据帧时的工件

2024-04-20 09:44:44 发布

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

我将数据组织成一个多索引数据帧。例如:

    Sweep  Time   Primary     Secondary  x720nm    x473nm      PMTShutter                                                      
Sweep0001 0.00000 -87.429810  -4.882812  0.000610  0.000305    0.000000
          0.00005 -87.445068  -4.882812  0.000610  0.001221    0.000000
          0.00010 -87.451172  -4.272460  0.000000  0.000916    0.000000
            ...        ...       ...       ...         ...  
Sweep0039 0.68655 -87.261963  -4.272461  0.000305  0.000916    0.000305
          0.68660 -87.258911  -4.272461  0.000305  0.000916    0.000305
          0.68665 -87.252808  -5.493164  0.000000  0.000916    0.000305
          0.68670 -87.261963  -4.272461  0.000305  0.000916    0.000305

绘制任何单个扫描都可以,但是当我绘制多个扫描时,我得到的这些工件基本上是直线(见下文)。你知道吗

这并不特定于matplotlib,因为pyqtgraph也会发生这种情况。你知道吗

打印单个记录道时不存在问题:

plt.plot(data.Time['Sweep0001'], data.Primary['Sweep0001'])

enter image description here

绘制多条记录道时出现问题:

plt.plot(data.Time['Sweep0001':'Sweep0002'], data.Primary['Sweep0001':'Sweep0002'])

enter image description here

plt.plot(data.Time['Sweep00-1':'Sweep0010'], data.Primary['Sweep0001':'Sweep0010'])

enter image description here


Tags: 数据datatimeplot记录绘制pltsecondary
1条回答
网友
1楼 · 发布于 2024-04-20 09:44:44

data.Time['Sweep001':'Sweep0002']data.Time['Sweep001']data.Time['Sweep002']连接。因此,时间值从0到N,然后又从0到N。 plt.plot因此从t=Nt=0画了一条线,造成了伪影。你知道吗

而是使用一个plt.绘图每行呼叫:

for i in range(1, 11):
    col = 'Sweep{:04d}'.format(i)
    plt.plot(data.Time[col], data.Primary[col])

相关问题 更多 >