Same color for different subplots
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Dyuman Joshi
2023-9-11
"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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Blue 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!