How do I rotate contour plot?
11 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Star Strider
2018-8-17
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!