擅长:python、mysql、java
<p>有很多选项(例如<a href="http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html" rel="noreferrer">centered spines</a>),但是在您的例子中,使用<a href="http://matplotlib.sourceforge.net/api/pyplot_api.html?highlight=axvline#matplotlib.pyplot.axvline" rel="noreferrer">^{<cd1>}</a>和<a href="http://matplotlib.sourceforge.net/api/pyplot_api.html?highlight=axvline#matplotlib.pyplot.axhline" rel="noreferrer">^{<cd2>}</a>可能是最简单的。</p>
<p>例如</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
xvec = 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()
</code></pre>
<p><img src="https://i.stack.imgur.com/rPhP3.png" alt="enter image description here"/></p>