Skip to content
Prev 106470 / 398513 Next

Rotating a distribution plot by 90 degrees

The gridBase package supports the mixing of traditional graphs in grid viewports, that may do what you want (But I am not a grid expert, so can't tell you anything more on that).  You could also create a plot, save it as a graphics file, read it back in rotated and add it to a plot, but that seems like even more work.

You will want to be careful and think things through even if you find an easy way to rotate the plots, if you do the default plot of a density, rotate it and put it next to a scatterplot, then the axes are unlikely to line up correctly (that is why my example explicitly sets xlim and ylim).  It seems to me that once you think through everything needed to get the axes to line up, switching the x and y arguments is simpler than calling another function to rotate things (unless of course the plot you want to rotate is an already canned routine that does not have a horiz argument or works just by switching x and y).