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 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2022년 8월 24일
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.
채택된 답변
Yash
2023년 8월 31일
편집: Yash
2023년 9월 1일
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!