This is my matrix
n =
46.4000 51.8000
44.8000 44.9000
67.2000 85.0000
54.4000 60.3000
43.2000 57.0000
51.2000 68.0000
75.2000 76.0000
44.8000 51.3000
67.2000 72.2000
70.4000 71.2000
If I plot it like bar(n, 'grouped') it shows
I want to change the default colors instead of blue red I want green and yellow
I tried like this way bar(n, 'grouped','g','y') But it is showing
can any one help me ?
By default, when you create a bar chart, the CData property contains a three-column matrix of RGB triplets. You can change the color for a particular bar by changing the corresponding row in the matrix. This property applies only when the FaceColor or EdgeColor property is set to 'flat' .
You can change the color of bars in a barplot using color argument. RGB is a way of making colors. You have to to provide an amount of red, green, blue, and the transparency value to the color argument and it returns a color.
You can use the 'FaceColor'
property of the handles to the objects:
n=[46.4000 51.8000
44.8000 44.9000
67.2000 85.0000
54.4000 60.3000
43.2000 57.0000
51.2000 68.0000
75.2000 76.0000
44.8000 51.3000
67.2000 72.2000
70.4000 71.2000];
bar_handle = bar(n,'grouped');
set(bar_handle(1),'FaceColor',[0,1,0])
set(bar_handle(2),'FaceColor',[1,1,0])
The documentation explains how to set the colors here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With