Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotating a plot?

Tags:

matlab

I have 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?

like image 538
smilingbuddha Avatar asked Feb 23 '11 06:02

smilingbuddha


People also ask

How do I rotate a plot in R?

With lattice or any grid graphics-based plot we can draw it in a rotated viewport: library(lattice) library(grid) grid. newpage() pushViewport(viewport(angle = 90, name = "VP")) upViewport() x <- 1:10 print(xyplot(x ~ x, groups = gl(2, 5), auto. key = TRUE), draw.in = "VP") or grid.


2 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.

like image 110
George Avatar answered Sep 29 '22 15:09

George


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)
like image 26
mc2 Avatar answered Sep 29 '22 14:09

mc2