Rotating plot with multiple y-axis
26 views (last 30 days)
Show older comments
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.
0 Comments
Answers (4)
Sanskar
on 27 Jun 2023
Edited: Sanskar
on 27 Jun 2023
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
0 Comments
Kanishk Singhal
on 27 Jun 2023
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])
Angelo Yeo
on 27 Jun 2023
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.
Sasha Kramer
on 16 Nov 2023
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...
0 Comments
See Also
Categories
Find more on Specifying Target for Graphics Output in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!