When I plot several curves on the same plot using hold on
, each curve defaults to the same color (blue). I'd like them to have all different colors.
One solution I've seen is to make a color vector, e.g. c = ['k', 'g', 'r', ...]
and loop over it, but I don't like this solution. Things will break if my number of plots is greater than the length of my color vector c
, and I don't want to have to define c
in every file.
Is there a better solution?
Best Answer
Try using
hold all
instead. Your curves should cycle over the colormap automatically. Fromhelp hold
:You can examine the colormap with
get(gca,'ColorOrder')
.