I am plotting some data in Python3 with matplotlib:
import matplotlib.pyplot as plt
d = list(range(0,10))
y = [ x*x for x in d]
plt.plot(d, y, c="r")
plt.ylabel("some unity")
plt.show()
where y
and d
are not the real data but were provided just to give a minimum working example.
What I would like to do is to put another scale and label on the right y-axis keeping the same graph.
So basically on the plot I have just one graph with one set of values in x and two set of values (two scales) in the y-axis one in the left and one in the right.
Is that possible?
NOTE: To make the question more clear, suppose I have the x
, y1
and y2
lists of values where y2
is a transformation of y1
. Instead of doing plot(x, y1)
and plot(x, y2)
which would result in 2 different curves, I want to have one curve (for example from plot(x,y1)
using y1
as the left y-axis scale and y2
as the right y-axis scale, (each one having its own unity-measurement/label).