I'm writing a script to draw plot via matplotlib, the following code is an analogy to my original script that reproduce the issue that I've encountered.
def func(ax, data, color, position): # A function for plotting
ax.plot(data[0], data[1], color=color)
ax.spines[position].set_color(color)
fig = plt.figure()
data_1 = [np.linspace(0, 1, 10), np.linspace(0, 10, 10)]
data_2 = [np.linspace(0, 1, 10), np.linspace(10, 0, 10)]
ax = fig.add_subplot(111)
func(ax, data_1, 'r', 'left')
ax_1 = ax.twinx()
func(ax_1, data_2, 'b', 'right')
plt.show()
The expected plot should have both y axis colored, however, only right spine is colored, as shown below.

When zooming into left spine you can find a red shadow around y-axis, that means my colored spine is covered by another one, how to solve this issue by only modifying func()?

