magmabyte
magmabyte

Reputation: 435

Placing the x-axes at a different y-value

I am overwhelmed by the customization options I have in Python. Is there a way to modify the x-axes to or add a x-axes at y=0 like in the Excel example? If not, is there a way to add an emphasized grid line?

Here are the python plot with x-axes at y=-0.10:

enter image description here

and the excel plot with x-axes at y=0:

enter image description here

The plot command is currently simply

plot = plt.plot(diff)
ax = plt.axes()
ax.grid(True)
plt.show()

where diff stores the data be plotted.

Upvotes: 1

Views: 66

Answers (1)

Saullo G. P. Castro
Saullo G. P. Castro

Reputation: 58885

You can use the set_position() method of the Spine class:

ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['bottom'].set_position(('data', 0))

Upvotes: 1

Related Questions