Draw axis lines or the origin for Matplotlib contour plot Draw axis lines or the origin for Matplotlib contour plot python python

Draw axis lines or the origin for Matplotlib contour plot


There are a number of options (E.g. centered spines), but in your case, it's probably simplest to just use axhline and axvline.

E.g.

import numpy as npimport matplotlib.pyplot as pltxvec = np.linspace(-5.,5.,100)                               x,y = np.meshgrid(xvec, xvec)z = -np.hypot(x, y)                                plt.contourf(x, y, z, 100)                             plt.colorbar() plt.axhline(0, color='white')plt.axvline(0, color='white')plt.show()

enter image description here


Can't you just overlay a straight line?

plt.plot([0,0],[-4,4],lw=3,'w')