[R] bar plot issues
Uwe Ligges
ligges at statistik.tu-dortmund.de
Thu Oct 20 18:14:45 CEST 2011
On 20.10.2011 18:03, Henri-Paul Indiogine wrote:
> Hi!
>
> I have 2 problems in drawing a stacked bar plot:
>
> (1) This is a stacked bar plot with more than 100 bars next to each
> other. So there should not be names at the bottom of the bars because
> the bars are too narrow. I tried arg.names=NULL but that does not
> work because R uses the row names from the data.frame.
>
> How can I suppress the placing of names below the bars?
It is the argument *names.arg* and it has to be set to NA.
> (2) The position of the legend is problematic. The legend is big, more
> than 20 items. It overlays the bars themselves and makes the plot
> unreadable. I would like to move it outside the plot and have tried
> legend("topleft") but R complains about missing information.
arrange it outside by, e.g. increasing the size of margins (see argument
"mar" in ?par) and place a separate legend (see ?legend) into the
margins (see xps argument in ?par).
> Here is what I have so far
>
> ########################################################
> barplot(t(file.codes),
> + beside = FALSE,
> + col = rainbow(ncol(file.codes)), names.arg=NULL,
> + legend = FALSE,
> + main = "Presidential documents - Codes per document",
> + xlab = "document", ylab = "number of codings")
> #######################################################
Not reproducible since we do not have file.codes.
Uwe Ligges
> Any ideas?
>
> Thanks,
> Henri-Paul
>
>
More information about the R-help
mailing list