Rotation of a contour plot

18 ビュー (過去 30 日間)
Mahi Nazir
Mahi Nazir 2014 年 7 月 9 日
コメント済み: Mattalabba 2018 年 11 月 15 日
I have a contour plot (Image1). I need to rotate it through a certain angle. If I save it as an image and then rotate it using transformation(or rotation) matrix, the whole plot including the axes are rotated(Image2). If I use imrotate for the matrix I have of the contour, the resultant contour doesn't actually rotate by the same angle which I specify (37 deg in the example, Image3) and more over sometimes the width of the plot decreases.
Can someone please help me overcome the problem. I want rotation of the contour plot without reducing the width and rotating exactly by the specified angle. Is it the aliasing effect?
Any help will be much appreciated. Many Thanks

採用された回答

Grzegorz Knor
Grzegorz Knor 2014 年 7 月 9 日
Look at this example:
a = 37;
[x,y] = meshgrid(linspace(-4,4,30));
z = exp(-x.^2/15-y.^2);
contour(x,y,z)
xlim([-5 5])
ylim([-5 5])
x = x*cosd(a) - y*sind(a);
y = y*cosd(a) + x*sind(a);
figure
contour(x,y,z)
xlim([-5 5])
ylim([-5 5])
Is that what you want?
  5 件のコメント
Mahi Nazir
Mahi Nazir 2014 年 7 月 9 日
This is super! That's what I exactly wanted. Thank you so much :) Cheers
Mattalabba
Mattalabba 2018 年 11 月 15 日
Is it correct that this method does not work anymore in MATLAB 2015 and newer?
I recieve the error 'Index exceeds matrix dimensions. Error in rotate (line 31): ax = ancestor(h(1),'axes');'
When I change
rotate(get(h,'children'),[0 0 1],a)
to
rotate(h,[0 0 1],a)
I get no error, but also nothing changes on the contourplot.
Or am I misunderstanding something?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by