필터 지우기
필터 지우기

axeshandle with matlab code

조회 수: 2 (최근 30일)
MattC
MattC 2023년 3월 7일
답변: Image Analyst 2023년 3월 7일
Hi, I have 4 plots in total which I trying to plot using axeshandle, subplot but for some reason I only 3 plots the first plot is missing. Please help how to fix this
%First plot
axeshandle(1)=subplot('position',[0.13 .808 .775 .097]);
plot (A_Table1.Time,A_Table1_Var1, '*')
% Second plot which has 3 plots in itself
Days = datetime(['03/06/2023';'03/07/2023'], 'InputFormat','MM/dd/yyyy', 'Format','MM/dd/yyyy');
Data = array2table([5 50; 50 40; 55 65], 'VariableNames',string(Days), 'RowNames',{'A','B','C'})
axeshandle(2)=subplot('position',[0.13 .641 .775 .106]);
VN = Data.Properties.VariableNames;
Rows = Data.Properties.RowNames;
tiledlayout(3,1)
for k = 1:3
nexttile
plot(categorical(VN), table2array(Data(k,:)))
title(Rows{k})
ylim([0 100])
end

답변 (2개)

Walter Roberson
Walter Roberson 2023년 3월 7일
You need to stick to using subplot() or using tiledlayout() -- mixing the two can be a challenge.
You have five plots, not four, by the way. You subplot() for axeshandle1, then you subplot() for axeshandle2, then you nexttile for three plots -- a total of five axes.
  댓글 수: 1
MattC
MattC 2023년 3월 7일
Sorry I new to this and I think I am just trying to achieve 4 subplots
1 for first plot
3 for second plot
I am not stuck to any 1 approach. I am flexible to using subplot or tiledlayout but do not know how to implement this.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2023년 3월 7일
Try it this way
% First plot on first axes
subplot(2, 1, 1); % Create second axes.
plot(rand(1,10), 'b.-', 'LineWidth', 2, 'MarkerSize', 20);
title('The first axes has 1 curve plotted')
grid on;
% First plot on second axes
subplot(2, 1, 2); % Create second axes.
plot(rand(1,10), 'b.-', 'LineWidth', 2, 'MarkerSize', 20);
% Second plot on second axes
hold on; % Don't blow away prior plots on this axes.
plot(rand(1,10), 'r.-', 'LineWidth', 2, 'MarkerSize', 20);
% Third plot on second axes
plot(rand(1,10), 'g.-', 'LineWidth', 2, 'MarkerSize', 20);
legend
hold off;
grid on;
title('The second axes has 3 curves plotted')

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by