3

This code (matplotlib.pyplot) gives me the plot in the link below:

plt.subplot(2, 1, 1)
plt.plot(px,py)

plt.subplot(2, 1, 2)
plt.plot(curve)

2 plots example --> I want to add a horizontal line in the second sub-plot at 100.000. How can I do that? The colors of both plots shall stay the same/synchronized.

Mike
  • 35
  • 1
  • 4

1 Answers1

6

You can use matplotlib.axes.Axes.axhline of matplotlib which adds a horizontal line across the axis. If you need to set any further parameters, refer to the official documentation

import matplotlib.pyplot as plt    
plt.axhline(100000, color="gray")
Giorgos Myrianthous
  • 36,235
  • 20
  • 134
  • 156