[R] Help with R graphics
marc_schwartz at me.com
Sat May 29 17:52:55 CEST 2010
On May 29, 2010, at 9:54 AM, Fabian wrote:
> I need to make a plot illustrating main characterisitig of river drainage data. For this I have 2 questions:
> how can I rotate a histogram -90° (or 270°) (like the horizontal=TRUE with plot)?
> how can I use split.screen to produce 3 plot with uneuqal size (1/5, 2/5, 2/5 of the screen width)?
> thank you very much in advance for your help
I don't see an obvious way to do this with either hist() or MASS::truehist(). There may be another function in a CRAN package that will automatically do this. Rotating a plot is not a basic R graphics transformation and there are some graphic functions that support this with specific code internally.
Paul posted a generalized way to do this with lattice/grid graphics back in 2003:
If you are plotting frequencies (counts), you can use barplot() which supports a 'horiz' argument. If you need to replicate the breakpoints used in hist() with a continuous variable, see ?cut and ?nclass, which is what hist() uses internally.
For splitting the overall plot into unevenly sized regions, you are better off using ?layout:
# Create a plot with 3 columns with uneven widths defined
layout(matrix(1:3, ncol = 3), widths = c(1/5, 2/5, 2/5))
# show the 3 regions
More information about the R-help