How to change color of bar graph?
Show older comments
Hello
So far my function only reads
function eval = plotupc(x)
bar(x,'histc')
end
When I try to change the color of the graph, it stops my graph from being a histogram. Also, how can I make it so that my graph starts at 0 rather than 1
Answers (2)
the cyclist
on 13 Mar 2013
hb=bar(x,'histc');
set(hb,'FaceColor','k')
3 Comments
Tyler
on 13 Mar 2013
the cyclist
on 14 Mar 2013
hb = bar(0:7,[-1 1 1 0 1 1 -1 0],'histc');
Image Analyst
on 14 Mar 2013
I'm just not understanding what the 'histc' option is for. It's not listed as a valid option to bar() so I think it's just ignored. So why are you passing it in? I don't have it in my code below.
Image Analyst
on 14 Mar 2013
Try this:
x = randi(10, [1,15])-5
xAxis = .5:length(x)
hb=bar(xAxis, x, 'BarWidth', 0.95);
set(hb,'FaceColor', [0.3 0.1 0.3]); % color = [R, G, B] in 0-1 range
% Now make it look nice.
fontSize = 20;
grid on;
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
title('Bar Chart', 'FontSize', fontSize);
ylabel('x', 'FontSize', fontSize);
xlabel('xAxis', 'FontSize', fontSize);
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!