'matplotlib: how to get 2 y axises with the same scale, and how to show the y axises label?

I'm trying to get the same scale for the y axises, however the label on the second y axis doesn't show. Any help to show it pls ?

x  = np.array(lisTxIndices)
y1 = np.array(lisTxCreationTime)
y2 = np.array(lisTxAppendTimeToBC)

fig, ax1 = plt.subplots()

#ax2 = ax1.twinx()
ax2 = ax1.twiny()
a,b = 0,10
ax1.set_ylim(a,b)
ax2.set_ylim(a,b)
ax1.plot(x, y1, 'g-')
ax2.plot(x, y2, 'b-')

ax1.set_xlabel('TxIndex')
ax1.set_ylabel('TxCreationTime (sec)', color='g')
ax2.set_ylabel('TxAppendTimeToBC (sec)', color='b')

plt.show()

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source