-2

Using matplotlib.animation.FuncAnimation, I made two 3d real-time graphs. I want to combine the two graphs into one.

When I tried to find similar examples, I could only find examples of 3d graphs, not "3d real-time." How do I combine two 3d real-time graphs into one? Is it possible?

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
dallll
  • 1

1 Answers1

0

As shown in this example:

...

def update_lines(num, lines):
    # Set data for each plot separately
    for line in lines:
        # NOTE: there is no .set_data() for 3 dim data...
        line.set_data(...) # Set data X and Y
        line.set_3d_properties(...) # it just means to set data on Z axis
    return lines

...

# Prepare 3d plot for each of your graphs
lines = [ax.plot([], [], [])[0] for _ in plots]

# Creating the Animation object
# Pass lines as an argument to FuncAnimation [fargs]
ani = animation.FuncAnimation(
    fig, update_lines, num_steps, fargs=(lines), interval=100)