I have to plot multiple lines and markers with matplotlib by creating a loop and I have already set the axes color cycle in the matplolibrc param file. In each cycle of the loop a set of markers and lines are created (lines are created by a separate command). But the marker and line colors are different as per the axes color cycle. I want each time the loop is run the marker and lines to be of the same color of that cycle.
I have included the reproducible code:
import numpy as np
import itertools
import matplotlib.pyplot as plt
m = 5
n = 5
x = np.zeros(shape=(m, n))
plt.figure(figsize=(5.15, 5.15))
plt.clf()
plt.subplot(111)
marker = itertools.cycle(('o', 'v', '^', '<', '>', 's', '8', 'p'))
for i in range(1, n):
x = np.dot(i, [1, 1.1, 1.2, 1.3])
y = x ** 2
plt.plot(x, y, linestyle='', markeredgecolor='none', marker=marker.next())
plt.plot(x, y, linestyle='-')
plt.ylabel(r'\textit{y}', labelpad=6)
plt.xlabel(r'\textit{x}', labelpad=6)
plt.show()
Using this code the output I get is:

I need the markers and lines plotted in their range to be of the same color. How can it be done in matplotlib?


plt.plot(x, y, marker=marker.next())?