Clear Filters
Clear Filters

How do I rotate contour plot?

11 views (last 30 days)
Ernest Adisi
Ernest Adisi on 17 Aug 2018
Commented: Star Strider on 21 Aug 2018
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?
  2 Comments
Star Strider
Star Strider on 21 Aug 2018
Please do not close questions that have an answer.

Sign in to comment.

Answers (1)

Star Strider
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.

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!