2017-04-01 266 views

回答

2

看着matplotlib spine placement demo你会发现你可以使用ax.spines['left'].set_position('zero')来移动刺。

import matplotlib.pyplot as plt 
import numpy as np 
import seaborn as sns 

x = np.linspace(-3,3) 
y = x**2 

fig, ax = plt.subplots() 
ax.set_ylim(-4,10) 
ax.set_xlim(-10,10) 
ax.plot(x, y) 
ax.spines['left'].set_position('zero') 
ax.spines['right'].set_color('none') 
ax.spines['bottom'].set_position('zero') 
ax.spines['top'].set_color('none') 

plt.show() 

enter image description here

+0

感谢您的帮助和链接! –