0

Problem

I would like to show chart after each alternation. The problem is that after plt.show() the context is cleared.

Question

How to preserve/restore context of matplotlib after plt.show(), so I can add new data, and then show updated chart?

Note: I did not need to update chart in place, I would like to have 2 charts.

Example

import matplotlib.pyplot as plt

plt.plot([1,2,3])
plt.show()

# how to restore context here, so the second graph will also contain first one data
plt.plot([3,2,1])
plt.show()
Result Expected
enter image description here enter image description here
MaciejLisCK
  • 3,706
  • 5
  • 32
  • 39

0 Answers0