Computing for a large number of data time series using matplotlib

I collected sensor data every 5 minutes for a month (30 days). This means that I have timer data with 288 * 30 data points.

I would like to scatter the data (x axis: time, y axis: sensor value). The following code is for testing.

import pandas as pd
from matplotlib import pyplot as plt
import numpy as np

# generate time series randomly (length: 1 month)
rng=pd.date_range("2015-11-11",periods=288*30,freq="5min")
ts=pd.Series(np.random.randn(len(rng)),rng)

nr=3
nc=1

fig=plt.figure(1)
fig.subplots_adjust(left=0.04,top=1,bottom=0.02,right=0.98,wspace=0.1,hspace=0.1)

for i in range(3):
    ctr=i+1
    ax=fig.add_subplot(nr,nc,ctr)

    ax.scatter(ts.index,ts.values)
    ax.set_xlim(ts.index.min(),ts.index.max())

plt.show()

I created random time series with 288 * 30 observations and tried to draw them in a scatter chart. However, as you can see, it is impossible to analyze the figure.

enter image description here

I want to redraw it, satisfying the following conditions:

  • I want a larger version of the figure . In other words, part of the data points of a certain time range (for example, 2 ~ 3 hours) are shown immediately. Then there should be enough space between adjacent points.

  • png pdf. , , ( pdf) , .

-, ?

, matplotlib, , .

+4
1

: v1 -

  • . , (, 2 ~ 3 ) . .

matplotlib x y . , ax.set_xlim, 2-3 . , 5 , 2 /(5 /) = 24,

ax.set_xlim(ts.index.min(),ts.index.min() + 24)

2- .

  1. png pdf. , , ( pdf) , .

savefig, . , set_xlim xlim , , . , ( ), .

/PDF , ( ), . Python. , . figsize=(width, height) set_size_inches(width, height) Figure . . width, , height, ; , 40 4 . , , , .

+3

Source: https://habr.com/ru/post/1617370/


All Articles