Rotating a plot in MATLAB?

Hi I have just obtained an x-y plot in MATLAB of the sine curve and I wish to rotate this plot by 90 degrees counter clockwise. How do I do this?

Answers


In the figure you have plotted, click 'View'->'Camera Toolbar'. Use the Roll Camera icon, and that should allow you to rotate your plot.

EDIT: You can also use the camroll function to do this programatically

camroll(90)

Note, this actually rotates the camera looking at the plot clockwise, not the plot itself. So if you want to rotate the plot 90 degrees counter-clockwise, you will need to rotate the camera 90 degrees clockwise.


Another solution is function view:

view([90 90])

In my opinion this is better solution because there is a problem with labels when one uses camroll function. See code below:

y = rand(1,10);
subplot(211)
plot(1:10,y)
xlabel('x')
ylabel('y')
view([-90 90])
subplot(212)
plot(1:10,y)
xlabel('x')
ylabel('y')
camroll(90)

The best way is to use view([az,el]) that works also for 3d plots.

  1. plot your graph using surf, mesh, etc. and put the graph manually in the desired position using the interactive rotate 3d tool at the tool bar. You see at the left side bottom of the plot the values for the horizontal rotation (azimuth, az) and the vertical elevation (el).

  2. Note the values for az and el and use view([az,el]) to plot.

(When choosing az and el manually it seems like it gives only 2d-plots since the parameters are to be set correctly. Values like [0,1], [0,1], ... normally not work.)


Need Your Help

Setting a system environment variable from a Windows batch file?

windows batch-file cmd environment-variables

Is it possible to set a environment variable at the system level from a command prompt in Windows 7 (or even XP for that matter). I am running from an elevated command prompt.

copy a single row from one datatable to other

c# asp.net ado.net datatable datarow

I have two datatables one has few rows other is empty.