Emily.SageMaker.AWS
Emily.SageMaker.AWS

Reputation: 332

Graph Line Parallel to X Axis in Matplotlib

I'm thinking this is extremely simple. I would like to graph the line y = 7.87. This graphs a line parallel to the y-axis, but I'm looking for something horizontal, parallel with x-axis. Any ideas?

    import matplotlib.pyplot as plt

    plt.axvline(x = 7.85)

    plt.show() 

Upvotes: 9

Views: 13735

Answers (1)

hitzg
hitzg

Reputation: 12691

It really is quite simple:

import matplotlib.pyplot as plt

plt.axhline(y=7.87)

plt.show() 

The h and v in the function names (axhline and axvline) stand for horizontal and vertical.

Upvotes: 17

Related Questions