Colormap won't change
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ian Harris
el 6 de Dic. de 2017
Comentada: Ian Harris
el 6 de Dic. de 2017
Colormap no longer changes the colour map used by a plot?
I declare some new colours:
cols = [0.60 0.86 0.91; % skyblue
0.90 0.96 0.94; % paleblue
0.82 0.71 0.48; % palebrown
0.87 0.42 0.41; % pink
0.97 0.65 0.52; % palepink
0.98 0.84 0.66; % sand
0.58 0.74 0.81; % midblue
0.60 0.86 0.72; % steel
1.00 0.97 0.50; % paleyellow
0.80 0.89 0.25; % lime
0.30 0.75 0.59; % turquoise
0.70 0.71 0.27; % olive
0.50 0.80 0.32; % palegreen
0.98 0.78 0.20; % mustard
0.70 0.57 0.46]; % chocolate
Then I construct my data array (multiple series)
Then I open a figure, and set the colormap to my colours.
Then I create axes, and again set their colormap to my colours.
I plot my series, and again set the colormap (both syntaxes this time).
Finally a legend, with - yes! - another colormap call.
f1 = figure;
orient landscape;
colormap(f1,cols)
ax = axes('Position',[0.1,0.1,0.8,0.8],'Box','on');
colormap(ax,cols)
plot(xvy,dy,'LineWidth',1);
colormap(ax,cols)
colormap(cols)
legend(labs,'Location','southwest')
colormap(ax, cols)
It still just displays seven Parula colours and recycles them for my remaining series (I have ten).
Obviously I've tried colormap calls everywhere separately as well.
Thanks for any obvious error spotting!
Harry
1 comentario
Stephen23
el 6 de Dic. de 2017
"...It still just displays seven Parula colours..."
I doubt that. Unless someone set the default ColorOrder to parula.
Respuesta aceptada
Stephen23
el 6 de Dic. de 2017
Editada: Stephen23
el 6 de Dic. de 2017
You are plotting lines using plot, which determines the line color using the axes ColorOrder property. This is explained in the plot documentation: " plot uses colors and line styles based on the ColorOrder and LineStyleOrder properties of the axes."
So line color has absolutely nothing to do with the colormap, and has absolutely nothing to do with parula: the color of lines is defined by the axes ColorOrder property. You might like to look at the line colors: do you see all of those colors in parula? Where?
You can search for "MATLAB Line ColorOrder" and find plenty of help:
If you want simple working examples of how to set the line ColorOrder, then have a look at the examples of one of my FEX submissions, e.g.:
Otherwise you can simply explicitly define the color when calling plot, or by setting the line color property once the lines have been created. Whatever works for you.
2 comentarios
Stephen23
el 6 de Dic. de 2017
Editada: Stephen23
el 6 de Dic. de 2017
@Ian Harris: it is worth understanding that the colormap and line ColorOrder have two very different goals: colormaps are almost always used to indicate the relationship between data values, i.e. to show how similar or different data values are. As such the colors actually represent data. In contrast the ColorOrder simply distinguishes different lines, and the colors do not represent data. The main goals are to be distinguishable and aesthetically attractive. It is surprisingly difficult to generate distinguishable but attractive colors, and thus most plotting software use some hand-picked set of colors.
"Thank you, that answered my question."
I hope that it helps. Remember to accept the answer that helps you most to resolve your question. Accepting answers is the easiest way for you to show you appreciation to the volunteers who come here and help you.
Más respuestas (1)
Ver también
Categorías
Más información sobre Colormaps 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!