フィルターのクリア

Rotating plot with multiple y-axis

14 ビュー (過去 30 日間)
Mohit
Mohit 2023 年 6 月 27 日
回答済み: Sasha Kramer 2023 年 11 月 16 日
Hello,
I'm trying to plot 3 graphs on a 4x4 tiledlayout. first graph is a plot placed in 1 row and 3 columns. Next is plot of 3 rows and 3 columns. Last plot is 3 row and 1 columns.
Although I can plot all the graphs correctly but I'm having problem woth orientation with the last plot. For the first and second plots no rotation is required but for the last plot I need it rotated by 90 degrees.
I'm using double Y-axis in all the plots so MATLAB is showing the following warning:
Warning: 3-D views not supported for axes with multiple coordinate systems.
Please suggest solution.
In plot 3, I have already tried interchanging x and y-axis but due to sclae difference between the two y-axis, the solution doesn't seem to be effective and thus right y-axis plot seems like a line compared to left y-axis.

回答 (4 件)

Sanskar
Sanskar 2023 年 6 月 27 日
編集済み: Sanskar 2023 年 6 月 27 日
Hi Mohit!
What I understand from your question is that you are trying to fir all three plot with third one rotated by 90 degree.
We can use rotate function to rotate by whatever degree you require. Following is the demo code:
figure;
x= 1:10;
tiledlayout(4, 4);
% First Plot
nexttile([1 4]);
h = plot( 2*x+3,x );
%Second Plot
nexttile([3 3]);
x = 1:100;
plot(x,y);
%Third Plot
nexttile([3 1]);
gca = plot(x,y);
%Rotating the third one
rotate(gca, [0 0 1], 90);
%here we are rotating about z-axis by 90 degree
Happy to help!
Sanskar

Kanishk Singhal
Kanishk Singhal 2023 年 6 月 27 日
Is this is the figure you are looking for? The third plot is for sin() rotated clockwise 90deg.
This can be achieved with tiledlayout and view.
x = 0:0.01:7;
tiledlayout(4,4);
nexttile([1 3])
plot(x,sin(x))
nexttile(5, [3 3])
plot(x,cos(x))
nexttile(8, [3 1])
plot(x,sin(x.^2))
view([90 90])
I'm attaching the matlab documentaion for both nexttile and view.
  2 件のコメント
Mohit
Mohit 2023 年 6 月 27 日
I have already tried both the solutions but they don't seem to work with a plot with multiple y-axis, ie when using yyaxis right command.
The warning when using the above solutions is the same as mentioned in the original question.
Mohit
Mohit 2023 年 6 月 27 日
PFA the full fig file

サインインしてコメントする。


Angelo Yeo
Angelo Yeo 2023 年 6 月 27 日
Hi Mohit,
Swapping input arguments for x-axis and y-axis in plot swaps x and y axis. For example,
fs = 1000; t = 0:1/fs:2-1/fs;
x = cos(2*pi*1*t);
y = sin(2*pi*1*t);
fig = figure('position',[0, 0, 420, 420]);
ax1 = axes(fig, 'Position', [0.1, 0.75, 0.6, 0.2]);
plot(ax1, t, x);
ax2 = axes(fig, 'Position', [0.1, 0.1, 0.6, 0.6]);
plot(ax2, x, y);
ax3 = axes(fig, 'Position', [0.77, 0.1, 0.2, 0.6]);
plot(ax3, y, t); % see the t and y are swapped.
I don't acutally understand what you mean by
In plot 3, I have already tried interchanging x and y-axis but due to sclae difference between the two y-axis, the solution doesn't seem to be effective and thus right y-axis plot seems like a line compared to left y-axis.
A more detailed explanation is needed for a further help.
  1 件のコメント
Mohit
Mohit 2023 年 6 月 27 日
PFA the following figure for clarity regarding the doubt. Both plots are plotted, i.e. bar chart horizontal with double data and two line plots which have very low values thus not clearly visible but are present there.

サインインしてコメントする。


Sasha Kramer
Sasha Kramer 2023 年 11 月 16 日
Has anyone managed to solve this problem? Mohit's original issue of not being able to rotate a yyaxis plot (specifically a multiple axis plot, giving the error: Warning: 3-D views not supported for axes with multiple coordinate systems) seems to still be an issue with none of the suggestions here providing a solution...

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by