I'm using LineCollection
in matplotlib to plot a large number of lines quickly and with different colors. However, I can't find any way to set a line marker for the lines, even after looking at the LineCollection documentation. Is there any way to have line markers when using LineCollection?
Note: Using pyplot.plot() is not an option as it's too slow for my use case, which is plotting about 200k lines.
Code used to generate example (original source):
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
lines = [[(0, 1), (1, 1)], [(2, 3), (3, 3)], [(1, 2), (1, 3)]]
lc = LineCollection(lines, colors=['r', 'g', 'b'])
fig = plt.figure()
ax1 = fig.add_subplot(1, 2, 1)
ax1.add_collection(lc)
ax1.autoscale()
ax1.set_title('Current')
# Doesn't seem to do anything
for l in ax1.lines:
l.set_marker('o')
ax2 = fig.add_subplot(1, 2, 2)
ax2.plot([0, 1], [1, 1], 'ro-')
ax2.plot([2, 3], [3, 3], 'go-')
ax2.plot([1, 1], [2, 3], 'bo-')
ax2.set_title('Goal')
plt.show()