Matplotlib: How To Prevent Transparent Color Overlay When Curve Overlaps?
For example we plot a line with transparent color here import numpy as np import matplotlib.pyplot as plt a = np.array([1, 2, 3, 4, 5]) b = 2*a plt.plot(a, b, 'blue', alpha=0.3) p
Solution 1:
A single line does not overlay itself. Hence you can concatenate the multiple plots into a single one.
import numpy as np
import matplotlib.pyplot as plt
a = np.array([1, 2, 3, 4, 5])
b = 2*a
A = np.tile(np.append(a,[np.nan]),3)
B = np.tile(np.append(b,[np.nan]),3)
plt.plot(A, B, 'blue', alpha=0.3)
plt.show()
This is essentially the inverse of this question How can I draw transparent lines where the color becomes stronger when they overlap?, where this effect was undesired.
Post a Comment for "Matplotlib: How To Prevent Transparent Color Overlay When Curve Overlaps?"