I am creating a simple line plot in Python where I want to plot three different data points on the same graph. data1 will be represented by values on the left side of the y-axis, where data2 and data3 will be represented by the same scale of values on the right side of the y-axis. This is fairly simple to do below:
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.plt(x,data1,'r')
ax2.plt(x,data2,'g')
ax2.plt(x,data3,'b')
plt.show()
Now if I want to set the labels on each side I can do:
ax1.set_ylabel('data1',color='r')
ax2.set_ylabel('data2\ndata3',color='g')
The problem with the above set of code is that the text of both 'data2' and 'data3' are colored green. How do I make it so the text of 'data2' is green and the text of 'data3' is blue?