我有以下情节:
我想通过刻度和所有内容将y轴移动到x = 0,我该怎么办?
答案 0 :(得分:2)
你去吧
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
x = np.linspace(-np.pi, np.pi, 100)
y = 2*np.sin(x)
ax = fig.add_subplot(111)
ax.set_title('centered spines')
ax.plot(x, y)
ax.spines['left'].set_position('center')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('bottom')
ax.spines['top'].set_color('none')
ax.spines['left'].set_smart_bounds(True)
ax.spines['bottom'].set_smart_bounds(True)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
更多示例:http://matplotlib.org/examples/pylab_examples/spine_placement_demo.html
答案 1 :(得分:0)
尝试
ax.spines['left'].set_position(('data', 0))