How can I plot a bar chart with 4 different y-axis and standard deviation?
Hello,
I would like to have a bar plot with 4 different categories. Each has got its own y-axis, as shown in the attached picture.
<</matlabcentral/answers/uploaded_files/79925/bar_4y-axis.JPG>>
I figured out that there is a possibility to add mutlitple axis to a plot <https://de.mathworks.com/matlabcentral/fileexchange/9016-addaxis (addaxis)>. I’m using MATLAB R2014a, but I have access to R2017a at my university, if needed.
This is my current code, based on this <https://de.mathworks.com/matlabcentral/answers/136433-how-to-add-errorbars example>:
function[]=test_multiple_axis_2()
w=[1.0,2.5,3.9,9.8,5.5,6.6,8.8,5.4,7.4,6.5];
x=[11.1,21.5,23.7,19.8,14.7,15.6,12.7,13.8,14.9,11.4];
y=[15.7,16.8,25.9,18.6,16.9,20.4,23.8,19.9,17.8,21.8];
z=[21.5,26.8,17.7,18.9,16.5,25.6,29.3,18.9,26.8,24.5];
std_w=[0.7,1.7,1.7,4.5,0.1,4.8,1.2,4.1,1.4,1.0];
std_x=[2.2,5.4,3.3,5.2,1.9,4.8,5.4,3.2,4.7,6.2];
std_y=[6.2,2.5,2.6,3.9,7.8,4.1,5.6,4.2,6.6,7.1];
std_z=[8.7,5.4,6.5,7.4,2.3,2.2,1.9,9.2,1.7,7.5];
hb = bar([1 2 3 4 5 6 7 8 9 10],[w’ x’ y’ z’])
legend(‘w’,’x’,’y’,’z’);
set(gca, ‘FontSize’,12,’XTick’,[1 2 3 4 5 6 7 8 9 10],’XTickLabel’,{‘A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’});
ylabel(‘unit w’)%Here should be the addaxis code
errbar = [std_w; std_x; std_y; std_z]; % CREATE ‘errbar’ MATRIX
yd = [w’ x’ y’ z’]’;
keyboard %i didn’t understand the following code
hold on
for k1 = 1:3
errorbar([1:3]+.22*(k1-2), yd(k1,:), errbar(k1,:), ‘.k’, ‘LineWidth’,2)
end
hold off
returnHello,
I would like to have a bar plot with 4 different categories. Each has got its own y-axis, as shown in the attached picture.
<</matlabcentral/answers/uploaded_files/79925/bar_4y-axis.JPG>>
I figured out that there is a possibility to add mutlitple axis to a plot <https://de.mathworks.com/matlabcentral/fileexchange/9016-addaxis (addaxis)>. I’m using MATLAB R2014a, but I have access to R2017a at my university, if needed.
This is my current code, based on this <https://de.mathworks.com/matlabcentral/answers/136433-how-to-add-errorbars example>:
function[]=test_multiple_axis_2()
w=[1.0,2.5,3.9,9.8,5.5,6.6,8.8,5.4,7.4,6.5];
x=[11.1,21.5,23.7,19.8,14.7,15.6,12.7,13.8,14.9,11.4];
y=[15.7,16.8,25.9,18.6,16.9,20.4,23.8,19.9,17.8,21.8];
z=[21.5,26.8,17.7,18.9,16.5,25.6,29.3,18.9,26.8,24.5];
std_w=[0.7,1.7,1.7,4.5,0.1,4.8,1.2,4.1,1.4,1.0];
std_x=[2.2,5.4,3.3,5.2,1.9,4.8,5.4,3.2,4.7,6.2];
std_y=[6.2,2.5,2.6,3.9,7.8,4.1,5.6,4.2,6.6,7.1];
std_z=[8.7,5.4,6.5,7.4,2.3,2.2,1.9,9.2,1.7,7.5];
hb = bar([1 2 3 4 5 6 7 8 9 10],[w’ x’ y’ z’])
legend(‘w’,’x’,’y’,’z’);
set(gca, ‘FontSize’,12,’XTick’,[1 2 3 4 5 6 7 8 9 10],’XTickLabel’,{‘A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’});
ylabel(‘unit w’)%Here should be the addaxis code
errbar = [std_w; std_x; std_y; std_z]; % CREATE ‘errbar’ MATRIX
yd = [w’ x’ y’ z’]’;
keyboard %i didn’t understand the following code
hold on
for k1 = 1:3
errorbar([1:3]+.22*(k1-2), yd(k1,:), errbar(k1,:), ‘.k’, ‘LineWidth’,2)
end
hold off
return Hello,
I would like to have a bar plot with 4 different categories. Each has got its own y-axis, as shown in the attached picture.
<</matlabcentral/answers/uploaded_files/79925/bar_4y-axis.JPG>>
I figured out that there is a possibility to add mutlitple axis to a plot <https://de.mathworks.com/matlabcentral/fileexchange/9016-addaxis (addaxis)>. I’m using MATLAB R2014a, but I have access to R2017a at my university, if needed.
This is my current code, based on this <https://de.mathworks.com/matlabcentral/answers/136433-how-to-add-errorbars example>:
function[]=test_multiple_axis_2()
w=[1.0,2.5,3.9,9.8,5.5,6.6,8.8,5.4,7.4,6.5];
x=[11.1,21.5,23.7,19.8,14.7,15.6,12.7,13.8,14.9,11.4];
y=[15.7,16.8,25.9,18.6,16.9,20.4,23.8,19.9,17.8,21.8];
z=[21.5,26.8,17.7,18.9,16.5,25.6,29.3,18.9,26.8,24.5];
std_w=[0.7,1.7,1.7,4.5,0.1,4.8,1.2,4.1,1.4,1.0];
std_x=[2.2,5.4,3.3,5.2,1.9,4.8,5.4,3.2,4.7,6.2];
std_y=[6.2,2.5,2.6,3.9,7.8,4.1,5.6,4.2,6.6,7.1];
std_z=[8.7,5.4,6.5,7.4,2.3,2.2,1.9,9.2,1.7,7.5];
hb = bar([1 2 3 4 5 6 7 8 9 10],[w’ x’ y’ z’])
legend(‘w’,’x’,’y’,’z’);
set(gca, ‘FontSize’,12,’XTick’,[1 2 3 4 5 6 7 8 9 10],’XTickLabel’,{‘A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’});
ylabel(‘unit w’)%Here should be the addaxis code
errbar = [std_w; std_x; std_y; std_z]; % CREATE ‘errbar’ MATRIX
yd = [w’ x’ y’ z’]’;
keyboard %i didn’t understand the following code
hold on
for k1 = 1:3
errorbar([1:3]+.22*(k1-2), yd(k1,:), errbar(k1,:), ‘.k’, ‘LineWidth’,2)
end
hold off
return bar plot, standard deviation, multiple axis MATLAB Answers — New Questions