Where in the axes properties (or elsewhere) is the "pointer" on the next color of ColorOrder ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
The command
hold all
holds the current line color in the ColorOrder, so that following plot commands continue cycling through it. This seems to be only a feature of high-level-functions like plot. However, there must be a change in the 'axes properties' (besides the 'NextPlot' property), something like a pointer telling the next plot, which color to be used.
My problem is that I use low-level-function 'line' and want to add another line(s) in the next color of ColorOrder. Is there a more simple way to realize this instead of getting the existing line objects color by some functions as get,findobj and then choosing a non-used color for current line, which could not really considered as cycling.
Thanks.
2 comentarios
Respuesta aceptada
José-Luis
el 12 de En. de 2013
Editada: José-Luis
el 12 de En. de 2013
Maybe not exactly what you wanted but a workaround:
fH = figure;
aH = axes;
lH = plot(rand(10,1),'r');
your_colors = get(fH,'DefaultAxesColorOrder');
colorIdx = find(ismember(your_colors,get(lH,'Color'),'rows'));
nextColorIdx = mod(colorIdx + 1, size(your_colors,1));
nextColor = your_colors(nextColorIdx,:);
I think creating your own custom color order and cycling through it would be better. The snippet I gave you will not work if the color of the line you plot is not in the default colors.
Más respuestas (2)
Walter Roberson
el 12 de En. de 2013
getappdata(gca, 'PlotColorIndex')
When it is non-empty, it is the index of the next color to plot.
2 comentarios
Walter Roberson
el 12 de En. de 2013
If I recall correctly, line() does not cause cycling through the color order; it is functionality built into plot()
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!