How to rotate domain, but the lon and lat are on the contour (not on the axis)
8 views (last 30 days)
Show older comments
eko supriyadi
on 28 Jun 2025
Commented: Torsten
on 29 Jun 2025
Dear all, as far we know Matlab will traditionally generate 4 white areas when using the following script on rotate domain:
figure;
p=pcolor(lon_rho,lat_rho,h2a);shading interp;
An example illustration is attached. Instead of generating a map like the illustration, I want the lon and lat to be directly placed on the generated contour, note the black numbers in the attachment (not on the matlab x and y axis). Is this possible?

and this is a perfect example of what I want to get:
2 Comments
Dyuman Joshi
on 28 Jun 2025
Moved: Dyuman Joshi
on 29 Jun 2025
Note that the aspect ratio of axes will get distorted as per the angle, so adjust them as per your requirement.
X = [1 2 3; 1 2 3; 1 2 3];
Y = X';
C = [3 4 5; 1 2 5; 5 5 5];
%Default orientation
pcolor(X,Y,C)
%Modified orientation
figure
axes
%rotate camera about viewing axis
camroll(30)
xlabel('X')
ylabel('Y')
%set(gca,'dataaspectratiomode','manual')
hold all
pcolor(X,Y,C)
As to why the ylabel moves to the right side, I do not know yet.
Accepted Answer
Walter Roberson
on 28 Jun 2025
Edited: Walter Roberson
on 28 Jun 2025
You need to first calculate the tilt angle of the valid part of the data, then rotate by the negative of that angle so that the valid part would lie along the x axis. Then draw that, and camorbit() the resulting graph to tilt the plotted axes back to the original angle.
2 Comments
Torsten
on 29 Jun 2025
theta = median(angle(:)); % take the main angle of the domain
throws an error because there is no argument to the angle function.
p = pcolor(X_rot, Y_rot, h); shading interp
h is undefined.
More Answers (0)
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!


