Filled error bars to a plot
Afficher commentaires plus anciens
Hello,
I have been trying to create some error bars in my MATLAB script. However, I think there are some problems. I have made a figure with three plots, and I wish to have "filled" error bars for the DO and pH. Additionally, the error bars for biomass have lines between the points, which I don't know how to remove. It would be nice if only the error bars were present.
I have inserted the code to my plot and data. Excel file is attached aswell.
growth = readtable("growthWT2.xlsx")
time = [growth.Time_h_];
timeOD = [growth.Time_h__1];
DO_1 = [growth.O21];
DO_2 = [growth.O22];
DO_3 = [growth.O23];
mean_DO = [growth.MeanO2];
S_DO = [DO_1 DO_2 DO_3];
stand_DO = std(S_DO,0,2);
pH_1 = [growth.pH1];
pH_2 = [growth.pH2];
pH_3 = [growth.pH3];
mean_pH = [growth.meanPH];
S_pH = [pH_1 pH_2 pH_3];
stand_pH = std(S_pH,0,2);
Bio_1 = [growth.biomass1];
Bio_2 = [growth.biomass2];
Bio_3 = [growth.biomass3];
mean_bio = [growth.MeanBio];
S_bio = [Bio_1 Bio_2 Bio_3];
stand_bio = std(S_bio,0,2);
% mean values
t = tiledlayout(2,1);
nexttile
yyaxis left
fill([time, flip(time)], [mean_DO+stand_DO, flip(mean_DO-stand_DO)], 'b', 'FaceAlpha', 0.3, 'EdgeColor', 'none')
hold on
plot(time, mean_DO, 'b')
ylabel('DO')
yyaxis right
fill([time, flip(time)], [mean_pH+stand_pH, flip(mean_pH-stand_pH)], 'r', 'FaceAlpha', 0.3, 'EdgeColor', 'none')
hold on
plot(time,mean_pH, 'r')
ylabel('pH')
legend('DO', 'DO Std Dev' ,'pH', 'pH Std dev')
nexttile
plot(timeOD,mean_bio,'o')
hold on
errorbar(timeOD, mean_bio, stand_bio)
ylabel('Biomass [g/L]')
legend('Biomass', 'Biomass Std Dev')
title(t,'Growth parameters of PR01 average value')
xlabel(t,'Time [h]')
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Graphics Performance dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

