How can I assign different colors to different bins of a single "bar/barh object"?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
cui,xingxing
el 11 de Jul. de 2021
Respondida: Ive J
el 11 de Jul. de 2021
For example, the first example in the official documentation.
y = [75 91 105 123.5 131 150 179 203 226 249 281.5];
bar(y)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/680848/image.jpeg)
This figure has 11 bins, this case through the "faceColor" property set to a color at the same time, but how to set the display for 11 different colors it ? (no Groups of Bars)
0 comentarios
Respuesta aceptada
Ive J
el 11 de Jul. de 2021
Well, you just needed to go through the doc for bar.
y = [75 91 105 123.5 131 150 179 203 226 249 281.5];
h = bar(y, 'FaceColor', 'flat', 'CData', randi([0, 1], numel(y), 3)); % change CData
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Graphics Object Programming 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!