Same color for different subplots
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
![](/matlabcentral/answers/uploaded_files/1478841/Screenshot_20230911_115028.jpg)
I want to plot some data in two subplots. To each datum are associated two parameters, which are the ones I'd like to plot, one for each subplot. I want the subplots to have the same color for the two parameters associated to the same datum, but different from the other ones, like in the picture. How can I do that?
3 comentarios
Dyuman Joshi
el 19 de Sept. de 2023
"can you help me with that please?"
@Ale_798 Please check my answer below.
Respuestas (1)
Dyuman Joshi
el 11 de Sept. de 2023
"Then I need to define an array of 10 different colors:"
Yes.
RGB colors are a 3 element vectors with values in the range [0, 1].
There are multiple ways to do that.
1 - Manually defining colors. In the method, you have the choice of choosing which colors you want to use.
color = [0 0 0; %black
0 0 1; %blue
0 1 0; %green
0 1 1; %blue+green=cyan
1 0 0; %red
1 0 1; %red+blue=magenta
1 1 0; %rea+green=yellow
0.5 0.5 0.5; %gray
0.5 0 0; %maroon
0 0.5 0; %lime
]
n = 10;
color = rand(n,3)
color = (randi(256,n,3)-1)/255
3 - Using in-built colormaps in MATLAB
color = hsv(n)
You can check out the available colormaps here - https://in.mathworks.com/help/matlab/ref/colormap.html?s_tid=doc_ta#buc3wsn-1-map
0 comentarios
Ver también
Categorías
Más información sobre Subplots 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!