79214941

Date: 2024-11-22 12:10:20
Score: 1
Natty:
Report link

Your second approach is quite close to what I think you want. You just need to store the original x-limits and then use those to reset the plot after it's resized:

import matplotlib.pyplot as plt

x1 = [3, 4]
y1 = [5, 8]
x2 = [2, 5]
y2 = [4, 9]

fig, ax = plt.subplots()
ax.plot(x1, y1)
xlim = ax.get_xlim()
ax.plot(x2, y2)
ax.set_xlim(xlim)
plt.show()
plt.close()

enter image description here

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Alex Duchnowski