2017-04-01 262 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

感謝您的幫助和鏈接! –