0

I want to have a single line that has two colors in parallel, e.g. for green and red:enter image description here

I have achieved this as follows:

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0,1,100)
y = np.exp(x)

plt.plot(x,y,color='r')
plt.plot(x,y+0.01,color='g')
plt.show()

The problem is that when I zoom in the lines start to separate. In addition, this approach does not work if the line is nearly vertical (then x must be increased). Is there anyway to plot a single line that has two parallel colors?

Thomas Wagenaar
  • 6,489
  • 5
  • 30
  • 73

0 Answers0