Can there be two FuncAnimation calls in the same program?

I have a figure with two subplots in it and I want to do animation on both the subplots at different intervals and different functionality. Is it possible to make two FuncAnimation calls? I copied an example program and modified it like below. Only the first animation was working. Is there any way to get this working? Will Artist Animation help here? If any one has insight on this please share your thoughts.

# -*- coding: utf-8 -*-
Created on Thu Sep 23 19:58:24 2021

@author: DELL

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

def data_gen(t=0):
    cnt = 0
    while cnt < 1000:
        cnt += 1
        t += 0.1
        yield t, np.sin(2*np.pi*t) * np.exp(-t/10.)

def init():
    ax.set_ylim(-1.1, 1.1)
    ax.set_xlim(0, 10)
    del xdata[: ]
    del ydata[: ]
    line.set_data(xdata, ydata)
    return line,

fig, ax = plt.subplots()
line, = ax.plot([  ], [  ], lw=2)
line1, = ax.plot([  ],[  ])
xdata, ydata = [  ], [  ]
x1 = [  ]
y1 = [  ]

def test(x):

def run(data):
    # update the data
    t, y = data
    xmin, xmax = ax.get_xlim()

    if t >= xmax:
        ax.set_xlim(xmin, 2*xmax)
    x1 = [x + 1 for x in xdata]
    y1 = [y + 1 for y in ydata]
    line.set_data(xdata, ydata)

    return line,

ani = animation.FuncAnimation(fig, run, data_gen, blit=False, interval=10,
                              repeat=False, init_func=init)

ani1 = animation.FuncAnimation(fig, test, blit= False, interval =10  )

There’s only one subplot in your example.

Sorry for being late. Yes in the example that I gave there is only one subplot. But my original requirement is two do animation in two different subplots. But to test if two FuncAnimation calls are possible I created the example with just one subplot. How is FuncAnimatation called? Is it called in a separate thread? If so can there be two separate threads for two FuncAnimation calls? Those were the questions I was wondering with. Could not find much documentation to address these questions. Appreciate any inputs

Two animations seem to work just fine:

import itertools
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

def data_gen1():
    for t in itertools.count():
        yield t, np.sin(2*np.pi*t/10) * np.exp(-t/100)

def data_gen2():
    for t in itertools.count():
        yield t, np.sin(2*np.pi*t/10) * np.exp(-t/10)

def init1():
    ax1.set_ylim(-1.1, 1.1)
    ax1.set_xlim(0, 10)
    del xdata1[:]
    del ydata1[:]
    line1.set_data(xdata1, ydata1)
    return line1,

def init2():
    ax2.set_ylim(-1.1, 1.1)
    ax2.set_xlim(0, 10)
    del xdata2[:]
    del ydata2[:]
    line2.set_data(xdata2, ydata2)
    return line2,

fig, (ax1,ax2) = plt.subplots(2)
line1, = ax1.plot([], [], lw=2)
xdata1, ydata1 = [], []
line2, = ax2.plot([], [], color='C1')
xdata2, ydata2 = [], []

def run1(data):
    t, y = data
    xmin, xmax = ax1.get_xlim()
    if t >= xmax:
        ax1.set_xlim(xmin, 2*xmax)
    line1.set_data(xdata1, ydata1)

def run2(data):
    t, y = data
    xmin, xmax = ax2.get_xlim()
    if t >= xmax:
        ax2.set_xlim(xmin, 2*xmax)
    line2.set_data(xdata2, ydata2)

ani1 = animation.FuncAnimation(fig, run1, data_gen1, interval=10, init_func=init1)
ani2 = animation.FuncAnimation(fig, run2, data_gen2, interval=500, init_func=init2)

Great! Thanks. This works very well