access to default line colors
19 views (last 30 days)
Show older comments
Roy Goodman on 27 Jul 2017
Answered: Steven Lord on 27 Jul 2017
Is there a way to easily specify a line color from the (relatively) new default line color ordering? What I'd like is to be able to replace the command
with something that gives the new default blue that's different from 'b'.
If not, and I assume not, then let me make this a feature request. Can you make the command
plot a line with the first color in the default ordering, etc?
This would be useful if I plot a line using 'plot(x,y)' and somewhere down the line want to add another line to the plot that is the same color.
Steven Lord on 27 Jul 2017
You can specify the color of a line not only via a LineSpec but also via specifying the line's 'Color' property in the plot call.
ax = axes;
for k = 1:20
h = plot(1:10, 1:10, '-o', ...
'Color', ax.ColorOrder(ax.ColorOrderIndex, :));
This will plot a new line 20 times with half a second pause between each plot, each time using the next color in the ColorOrder property of the axes.
You can define any colors col and do
col = jet(5);
Oh, I see what you mean. I realize this is not the solution you're seeking, but I think I'd write a new function called myplot that would parse the inputs and then call plot.
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!