How to plot error bars on multiple data sets on an arrhenius plot?
Mostrar comentarios más antiguos
Hi! I am trying to plot error bars for each individual data point for the figure shown below. I imported an excel file and these are already the averages of the values for each point. I have calculated the standard deviations, but now need to add the error bar to each point. The code I used is shown below, in which I also had to do line fits for my data set. I need a deviation point for each y value. Any help is appreciated! Thanks!

%Enter file name here f = 'arrhenius_loading_comparison4x.xlsx';
%5 VOL% Avg 4X low sheetName = '5vol4xavg'; x_1 = xlsread(f, sheetName,'M7:M10'); y_1= xlsread(f, sheetName,'N7:N10'); %5 VOL% Avg 4X high sheetName = '5vol4xavg'; x_2 = xlsread(f, sheetName,'M4:M7'); y_2= xlsread(f, sheetName,'N4:N7');
%10 VOL % cell 2 low sheetName = '10vol2_4x'; x_3 = xlsread(f, sheetName,'F7:F10'); y_3= xlsread(f, sheetName,'I7:I10'); %10 VOL % cell 2 high sheetName = '10vol2_4x'; x_4 = xlsread(f, sheetName,'F4:F7'); y_4= xlsread(f, sheetName,'I4:I7');
%25volcell avg (4x)low sheetName = '25vol4xavg'; x_5 = xlsread(f, sheetName,'M6:M9'); y_5= xlsread(f, sheetName,'N6:N9'); %25volcell avg (4x)high sheetName = '25vol4xavg'; x_6 = xlsread(f, sheetName,'M3:M6'); y_6= xlsread(f, sheetName,'N3:N6');
%50 VOL% cell 4x Avg low sheetName = '50vol4xavg'; x_7 = xlsread(f, sheetName,'M7:M10'); y_7= xlsread(f, sheetName,'N7:N10'); %50 VOL% cell 4x Avg low sheetName = '50vol4xavg'; x_8 = xlsread(f, sheetName,'M4:M7'); y_8= xlsread(f, sheetName,'N4:N7');
figure(1) %yyaxis left plot(x_1, y_1, 'b.', x_3, y_3, 'r.', x_5, y_5, 'g.', x_7, y_7, 'k.', x_2, y_2, 'b.', x_4, y_4, 'r.', x_6, y_6, 'g.', x_8, y_8, 'k.','MarkerSize',18);
c = polyfit(x_1, y_1,1); % Display evaluated equation y = m*x + b disp(['Equation is y = ' num2str(c(1)) '*x + ' num2str(c(2))]) % Evaluate fit equation using polyval y_est = polyval(c,x_1); % Add trend line to plot hold on plot(x_1,y_est,'b-','LineWidth',1) hold off
c = polyfit(x_2, y_2,1); % Display evaluated equation y = m*x + b disp(['Equation is y = ' num2str(c(1)) '*x + ' num2str(c(2))]) % Evaluate fit equation using polyval y_est = polyval(c,x_2); % Add trend line to plot hold on plot(x_2,y_est,'b-','LineWidth',1) hold off
c = polyfit(x_3, y_3,1); % Display evaluated equation y = m*x + b disp(['Equation is y = ' num2str(c(1)) '*x + ' num2str(c(2))]) % Evaluate fit equation using polyval y_est = polyval(c,x_3); % Add trend line to plot hold on plot(x_3,y_est,'r-','LineWidth',1) hold off
c = polyfit(x_4, y_4,1); % Display evaluated equation y = m*x + b disp(['Equation is y = ' num2str(c(1)) '*x + ' num2str(c(2))]) % Evaluate fit equation using polyval y_est = polyval(c,x_4); % Add trend line to plot hold on plot(x_4,y_est,'r-','LineWidth',1) hold off
c = polyfit(x_5, y_5,1); % Display evaluated equation y = m*x + b disp(['Equation is y = ' num2str(c(1)) '*x + ' num2str(c(2))]) % Evaluate fit equation using polyval y_est = polyval(c,x_5); % Add trend line to plot hold on plot(x_5,y_est,'g-','LineWidth',1) hold off
c = polyfit(x_6, y_6,1); % Display evaluated equation y = m*x + b disp(['Equation is y = ' num2str(c(1)) '*x + ' num2str(c(2))]) % Evaluate fit equation using polyval y_est = polyval(c,x_6); % Add trend line to plot hold on plot(x_6,y_est,'g-','LineWidth',1) hold off
c = polyfit(x_7, y_7,1); % Display evaluated equation y = m*x + b disp(['Equation is y = ' num2str(c(1)) '*x + ' num2str(c(2))]) % Evaluate fit equation using polyval y_est = polyval(c,x_7); % Add trend line to plot hold on plot(x_7,y_est,'k-','LineWidth',1) hold off
c = polyfit(x_8, y_8,1); % Display evaluated equation y = m*x + b disp(['Equation is y = ' num2str(c(1)) '*x + ' num2str(c(2))]) % Evaluate fit equation using polyval y_est = polyval(c,x_8); % Add trend line to plot hold on plot(x_8,y_est,'k-','LineWidth',1) hold off
xlabel ('1000/T (K)', 'FontSize', 12) ylabel ('log(\sigma) s/cm', 'FontSize',12) legend ('5 vol%', '10 vol%', '25 vol%', '50 vol%')
legend boxoff
5 comentarios
madhan ravi
el 7 de Nov. de 2018
Brice Harkey
el 7 de Nov. de 2018
the cyclist
el 7 de Nov. de 2018
The errorbar command is certainly the canonical way to do this. Can you post the code that throws an error and/or indicate what "doesn't plot it correctly" means exactly? It's presumably just a syntax problem.
Brice Harkey
el 7 de Nov. de 2018
the cyclist
el 10 de Nov. de 2018
You posted the error, which is helpful, but not the code that throws that error.
It would be enough (and probably easier to debug) if you post
- the line where you call errorbar
- a MAT file containing the input variables you used
Respuestas (0)
Categorías
Más información sobre Plot Settings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!