Clear Filters
Clear Filters

How to insert a break in my y axis?

108 views (last 30 days)
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

Accepted Answer

Dyuman Joshi
Dyuman Joshi on 10 Oct 2023

More Answers (0)

Categories

Find more on Chemistry in Help Center and File Exchange

Tags

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!