Help With Bar Position
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello!!
I would like to create a bar graph that has four bars. The first three show data, the last is a percent increase of one variable over one of the other data bars. I would like the fourth bar to be further away from the other three. Please help!!
%Data
Data=[8 12]
%Percent Increase
PI=[50]
Names={'Before','After','%Change'}
figure name (One Vs The Other);
bar(1,Data(1),'FaceColor','g');
ylim([0,100]);
hold on
bar(2,Data(2),'FaceColor','b');
%I want the following bar to be spaced further out from the first two...)
bar(3,PI,'FaceColor','r');
labels=(Names);
set(gca,'XTick',[1 2 3]);
set(gca,'XTickLabel',labels);
xlabel('Condition');
ylabel('Sales');
title('Sales Before and After Advertising');
box off
yyaxis right
ylabel('Percent Increase');
0 comentarios
Respuestas (1)
Luna
el 20 de Nov. de 2018
Hi Naomi,
You can add zero value bars to add it to further I think.
Try that below:
%Data
Data=[8 12]
%Percent Increase
PI=[50]
Names={'Before','After','%Change', '','', 'other'}
figure name (One Vs The Other);
bar(1,Data(1),'FaceColor','g');
ylim([0,100]);
hold on
bar(2,Data(2),'FaceColor','b');
%I want the following bar to be spaced further out from the first two...)
bar(3,PI,'FaceColor','r');
bar(4,0);
bar(5,0);
bar(6,1,'FaceColor','m');
labels=(Names);
set(gca,'XTick',[1 2 3 4 5 6]);
set(gca,'XTickLabel',labels);
xlabel('Condition');
ylabel('Sales');
title('Sales Before and After Advertising');
box off
yyaxis right
ylabel('Percent Increase');
0 comentarios
Ver también
Categorías
Más información sobre Environment and Settings 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!