Reputation: 83157
I draw a plot with 2 lines with pyplot.plot
. Is there any way to specify several markers at once?
import matplotlib.pyplot as plt
data = [[0, 0], [1, 2], [1, 3], [1, 4]]
plt.plot(c, marker = 'o') # the two lines will have the marker, which I don't want.
plt.show()
I know I can loop around the lines:
import matplotlib.pyplot as plt
markers = ['*', 'D']
for i in range(len(data[0])): plt.plot(map(list, zip(*data))[i], marker = markers[i])
plt.show()
but I wonder if there exist a better solution, e.g. one that would look like plt.plot(c, marker = ('*', 'D'))
.
Upvotes: 0
Views: 53
Reputation: 10771
I don't believe the specific syntax you are looking for exists. I think it introduces too many ambiguities and probably violates the Python principal 'explicit is better than implicit'.
You can do this,
import numpy as np
from matplotlib import pyplot as plt
data = np.array([[0, 0],
[1, 2],
[1, 3],
[1, 4]])
plt.plot(data[:,0], '*-', data[:, 1], 'D-')
Honestly though, I don't really feel that this is 'better' than a loop.
Upvotes: 1