How to implement the function similar to paging in python Matplotlib

demand: if there are 1000 pieces of data and 1000 points every day for a total of 1000 days, and if you put the data of 1000 * 100days in a view, you can"t see the specific performance of the data intuitively. Is there any way to achieve a similar function by looking at 1000 pieces of data at a time, and then by clicking on the data on the next page, can Matplotlib achieve such a function?

x = [1,2,3]
day1 = [1,2,3]
day2 = [2,4,6]
......
dayn = [100,200,300]
plt.plot(x,dayn ,color="red")

how to draw a picture day by day, and only see the data of one day at a time

Apr.07,2021

of course, you can use the slider component of matplotlib.

the following example shows different images by dragging the slider

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider

fig, ax = plt.subplots()
plt.subplots_adjust(left=0.25, bottom=0.25)

axindex = plt.axes([0.25, 0.1, 0.65, 0.03], facecolor='lightgoldenrodyellow')
sindex = Slider(axindex, 'Index', 1, 10, valinit=2, valstep=1)

def update(val):
    index = int(sindex.val)
    ax.clear()
    ax.set_xlabel('index={}'.format(index))
    x = np.arange(0, 2*np.pi, 0.01)
    y = np.sin(x * (2 ** index))
    ax.plot(x, y)
    fig.canvas.draw_idle()
sindex.on_changed(update)

update(None)
plt.show()

Animation effect

if you want to output a report, you can use PDF paging instead.

Menu