How do I rotate contour plot?
11 views (last 30 days)
Show older comments
I want this contour image to have the wake moving from left to right with y, along the x axis, and conversely x along y. I've managed to change the axis but can't get the image to rotate appropriately any ideas?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/193994/image.png)
2 Comments
Answers (1)
Star Strider
on 17 Aug 2018
It would help to know how you calculated your data, and what you’re plotting. Rotating the plot might be as simple as reversing the order of your independent variable matrices, and either transposing ‘Z’ or letting contourf default to the correct orientation.
Example —
x = linspace(0, 0.35, 75); % Create Data
y = linspace(0, 0.2, 50); % Create Data
[X,Y] = meshgrid(x,y); % Create Data
Z = sin(X*3*pi) .* exp(-0.5*Y); % Create Data
figure(1)
contourf(x, y, Z) % ‘Normal’ Orientation (Vectors)
colorbar
figure(2)
contourf(X, Y, Z) % ‘Normal’ Orientation (Matrices)
colorbar
figure(3)
contourf(y, x, Z') % ‘Rotated’ Orientation (Vectors)
colorbar
figure(4)
contourf(Y, X, Z) % ‘Rotated’ Orientation (Matrices)
colorbar
I use meshgrid here. It produces different output matrices from those ndgrid would produce, so you may need to experiment with this if you used other functions.
0 Comments
See Also
Categories
Find more on Contour Plots 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!