Code does not show the effect in .mlx but when run in command window it will show the effect and how to make the labels in bold
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello master's
I'm not sure about this if some command won't run in .mlx becuase if i run my code with this code
clc, clearvars, close all
data1=readtable("FTIR.xlsx", 'PreserveVariableNames',true);
x1=data1.("F1(DCM_eluted)");
FF1_DCM_eluted=data1.("y1");
FF2_THF_eluted=data1.("y2");
FF3_EA_eluted=data1.("y3");
FF4_MeOH_eluted=data1.("y4");
FF5_H2O_eluted=data1.("y5");
Fwhole_sugar=data1.("y6");
figure()
h=stackedplot(x1,[FF1_DCM_eluted,FF2_THF_eluted,FF3_EA_eluted, ...
FF4_MeOH_eluted,FF5_H2O_eluted,Fwhole_sugar]);
%labels
h.XLabel = {'Wavenumber (cm^-1)'};
h.DisplayLabels = {'','','','','',''};
h.AxesProperties(1).LegendLabels = {'F1-DCM-eluted'};
h.AxesProperties(1).LegendVisible = 'on';
h.AxesProperties(1).LegendLocation = 'northwest';
h.AxesProperties(2).LegendLabels = {'F2-THF-eluted'};
h.AxesProperties(2).LegendVisible = 'on';
h.AxesProperties(2).LegendLocation = 'northwest';
h.AxesProperties(3).LegendLabels = {'F3-EA-eluted'};
h.AxesProperties(3).LegendVisible = 'on';
h.AxesProperties(3).LegendLocation = 'northwest';
h.AxesProperties(4).LegendLabels = {'F4-MeOH-eluted'};
h.AxesProperties(4).LegendVisible = 'on';
h.AxesProperties(4).LegendLocation = 'northwest';
h.AxesProperties(5).LegendLabels = {'F5-H2O-eluted'};
h.AxesProperties(5).LegendVisible = 'on';
h.AxesProperties(5).LegendLocation = 'northwest';
h.AxesProperties(6).LegendLabels = {'Whole Sugar'};
h.AxesProperties(6).LegendVisible = 'on';
h.AxesProperties(6).LegendLocation = 'northwest';
%colors
h.LineProperties(1).Color = 'r';
h.LineProperties(2).Color = 'g';
h.LineProperties(3).Color = 'b';
h.LineProperties(4).Color = 'm';
h.LineProperties(5).Color = 'c';
h.LineProperties(6).Color = 'k';
%linewidth
h.LineProperties(1).LineWidth = 2;
h.LineProperties(2).LineWidth = 2;
h.LineProperties(3).LineWidth = 2;
h.LineProperties(4).LineWidth = 2;
h.LineProperties(5).LineWidth = 2;
h.LineProperties(6).LineWidth = 2;
%this two last line of code will not show any effect in .mlx file but running in command window it will show effect
ax = findobj(h.NodeChildren, 'Type','Axes');
set(ax, 'XTick', 500:500:4000, 'XLim', [500,4000],'XDir','reverse');
of Adam Danz it will not show any effect
but if i run it in the command window it will show this
2 commentaires
Walter Roberson
le 24 Août 2022
I am not sure why you say that it will not show any effect? The top plot does show a reversed x axes which is what you want.
Réponse acceptée
Yash
le 31 Août 2023
Modifié(e) : Yash
le 1 Sep 2023
Hi Stark,
I was able to reproduce the same issue in my device.
I have found out that after you use the "set()" function, the axes properties change but the output is not updated in the MATLAB Live Script output pane.
I suggest you to use normal MATLAB script ('.m' file) instead of MATLAB Live Script ('.mlx' files) to get the correct output.
If you still want to use '.mlx' file, one workaround is to save the figure and analyse that.
% before you define h
f = figure
% at the end
saveas(f,'f.png');
You can see that the saved figure has the correct properties.
You can also flip your data by using the fliplr() function and plot that. However, please note that this won't change the xTicks.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Environment and Settings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!