Reputation: 894
Plotting two lines with a single plot
command should not be easy?
import matplotlib.pyplot as plt
plt.plot([[1,2],[5,6]], c=['k','g'])
ValueError: Invalid RGBA argument
I just need two lines, one is black and the other green. What is going on here?
Upvotes: 2
Views: 590
Reputation: 7632
If you want that very much...
You can control the colors that will be cycled through using cycler
.
from matplotlib import pyplot as plt
from cycler import cycler
ax = plt.subplot(111)
ax.set_prop_cycle(cycler('color', ['black', 'green']))
ax.plot([[1,2],[5,6]])
Upvotes: 0
Reputation: 2763
You need to have 2 lines, not 2 points, to plot 2 lines.
import matplotlib.pyplot as plt
plt.plot(x1, y1, c = 'k')
plt.plot(x2, y2, c = 'g') #x1, y1, x2, y2 should be multiple points
Upvotes: 1