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 Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by