colormap doesn't work with bar plots in 2019a

34 visualizaciones (últimos 30 días)
Clay Fulcher
Clay Fulcher el 27 de Mzo. de 2020
Comentada: KV el 9 de Feb. de 2024
I have been changing the colormap in bar charts for decades. It doesn't seem to work now with bar charts in 2019a.
Previously all I had to do to change the colormap in an existing bar chart to copper: colormap copper
Now it does nothing.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 27 de Mzo. de 2020
Not sure if it's changed, but here's an example borrowed from the doc on bar.
y = [1 3 5; 3 2 7; 3 4 2];
b = bar(y,'FaceColor',"flat");
for k = 1:size(y,2)
b(k).CData = k;
end
If I want to use a different colormap, I could do this.
colormap copper
y = [1 3 5; 3 2 7; 3 4 2];
b = bar(y,'FaceColor',"flat");
for k = 1:size(y,2)
b(k).CData = k;
end
  2 comentarios
Clay Fulcher
Clay Fulcher el 27 de Mzo. de 2020
Thanks Cris. That works and I'm back running again. It's now a much more complicated way to change the colormap in a bar plot. In the past, we didn't have to go back and change the CData for each bar. Kind of frustrating since previous scripts plotting with bar and colormap no longer work. Thanks again.
KV
KV el 9 de Feb. de 2024
I discovered this issue too today, working through some legacy code! This solution breaks a lot of older code that was used to produce plots.
Kind of silly and quite a pity now that it'll take a for loop with each bar command to change facecolors....

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by