how do i change barwidth of 2 bars simaltaneously

1 view (last 30 days)
% Plotting the average delay for all node sizes in bar form
figure();
bar( [average_delays_iot; average_delays_fog]',10 );
xlabel('Number of Nodes');
ylabel('Average Delay');
title('Average Delay vs. Number of Nodes');
grid on;
%only the barwidth of average fog delays is changing
  2 Comments
muska
muska on 17 May 2023
Edited: muska on 17 May 2023
i want both barwidths to change
Adam Danz
Adam Danz on 17 May 2023
I have a feeling your code doesn't reproduce the problem because I see two set of bar plots but only one plotting command. Are you specifying the bar width with the same value for both sets of bars?

Sign in to comment.

Answers (1)

Mathieu NOE
Mathieu NOE on 17 May 2023
hello
I don't think there is a problem with bar
simply when you choose a wider bar one can get hidden behind the front bar
you may want to play with the transparency if you need to see both with wide bars
figure();
average_delays_iot = rand(1,5)*3;
average_delays_fog = rand(1,5)*5;
bar( [average_delays_iot; average_delays_fog]',1 );
xlabel('Number of Nodes');
ylabel('Average Delay');
title('Average Delay vs. Number of Nodes');
grid on;
figure();
average_delays_iot = rand(1,5)*3;
average_delays_fog = rand(1,5)*5;
b1 = bar( [average_delays_iot; average_delays_fog]',2 );
b1(1).FaceAlpha = 0.5;
b1(2).FaceAlpha = 0.7;
xlabel('Number of Nodes');
ylabel('Average Delay');
title('Average Delay vs. Number of Nodes');
grid on;

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!