Filter löschen
Filter löschen

How to insert a break in my y axis?

109 Ansichten (letzte 30 Tage)
Ludovica Varriale
Ludovica Varriale am 10 Okt. 2023
Beantwortet: Dyuman Joshi am 10 Okt. 2023
I would like to add a break in my left y-axis. Which function should I use according to my code?
%Data
x=[0,6,24,48,72];
Glu1=[1.71,1.69,1.48,0.98,0.69];
errGlu1=[0.09,0.03,0.12,0.06,0.03];
Fru1=[42.92,41.99,37.45,24.34,13.10];
errFru1= [2.01,0.83,0.91,3.20,2.99];
Et1=[0,0.13,1.40,5.16,8.97];
errEt1=[0.15,0.10,0.24,0.30,0.85];
Gly1=[0,0,0.08,0.28,0.33];
errGly1=[0.02,0.03,0.03,0.08,0.03];
figure
hold on
xlabel('Time [h]');
fontsize(12,"points");
yyaxis left
ylabel('Glucose, Fructose [g/L]');
ax= gca;
ax.YAxis(1).Color = [0 0 0];
Glucose= plot(x,Glu1,'^-','LineWidth',2);
Fructose= plot(x,Fru1,'^-','LineWidth',2);
errorbar(x,Glu1,errGlu1,'LineStyle','none','Color','black');
errorbar(x,Fru1,errFru1,'LineStyle','none','Color','black');
ylim([0 45])
%Colorder for the left side
newcolors1 = [0.83 0.14 0.14
1.00 0.54 0.00];
colororder(newcolors1)
yyaxis right
ylabel('Ethanol, Glycerol [g/L]');
ax.YAxis(2).Color = [0 0 0];
Ethanol= plot(x,Et1,'v-', 'LineWidth',2);
Glycerol= plot(x,Gly1,'v-','LineWidth',2);
errorbar(x,Et1,errEt1,'LineStyle','none','Color','black');
errorbar(x,Gly1,errGly1,'LineStyle','none','Color','black');
ylim([0 12]);
%Colorder for the right side
newcolors2 = [0.47 0.25 0.80
0.25 0.80 0.54];
colororder(newcolors2)
% Legend
legend([Glucose, Fructose, Ethanol, Glycerol],'Glucose','Fructose','Ethanol','Glycerol');
hold off

Akzeptierte Antwort

Dyuman Joshi
Dyuman Joshi am 10 Okt. 2023

Weitere Antworten (0)

Kategorien

Mehr zu Chemistry finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by