I am using matplotlib.pyplot
to plot several curves on the same graph. Sometimes they have equal values, so the last one hides the others, like this:
import matplotlib.pyplot as plt
plt.figure()
plt.plot([1,2,3,4], label="up")
plt.plot([1,2,3,2.5], label="down")
plt.show()
I would like the curves to be slightly shifted so they don't hide one another, like this:
Is there any proper way to do this, without changing the actual values I am plotting?
Update: The best answer so far (for my case) is that of theImportanceOfBeingErnest. However, if I have n curves to plot, instead of just 2, I would have to compute the accumulated offset for each. But given the complex calculations that this answer gets into, I suppose there is no way for matplotlib to do this automatically?
PS: since my values are all multiples of 0.5, the (slight) shifting doesn't risk to create a confusion about the actual value...