import matplotlib.pyplot as plt import numpy as np t = np.linspace(0, 39*np.pi/2, 1000) x = t*np.cos(t)**3 y = 9*t*np.sqrt(abs(np.cos(t))) + t*np.sin(0.2*t)*np.cos(4*t) segments = [ (0, 200, 'orange'), (200, 600, 'magenta'), (600, 1000, 'red') ] for start, end, color in segments: plt.plot(x[start:end], y[start:end], c=color) plt.show()