Skip to content

bar plot issues

7 messages · Henri-Paul Indiogine, Uwe Ligges

#
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?


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

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")
#######################################################

Any ideas?

Thanks,
Henri-Paul
#
On 20.10.2011 18:03, Henri-Paul Indiogine wrote:
It is the argument *names.arg* and it has to be set to NA.
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).
Not reproducible since we do not have file.codes.


Uwe Ligges
#
Hi Uwe!  Thanks for the feedback.   However, now the graph does not
draw the y-axis nor labels and gives the following error message:

Error in barplot.default(t(file.codes), beside = FALSE, names.arg = NA,  :
  incorrect number of names

This is the R code now:

barplot(t(file.codes), beside = FALSE, names.arg=NA, legend = FALSE,
main="test stacked bar plot", xlab="documents", ylab="number of
codes", col=rainbow(ncol(file.codes)))


I have head(file.codes) at the bottom of this email.

Thanks,
HP

2011/10/20 Uwe Ligges <ligges at statistik.tu-dortmund.de>:
Achievement Diversity Economy EducEquity Gap HumanBenefit
DCPD-200900575.scrb           2         2       4          5   2            1
DCPD-200900595.scrb           2         0      12          0   2            1
DCPD-200900884.scrb           1         0      12          0   1            1
DCPD-201000036.scrb           2         0       1          0   1            0
DCPD-201000130.scrb           1         0       1          0   2            0
DCPD-201000636.scrb           4         0      10          3   2            1
                    InternatComp MathSciEng Poverty Standards TechnoSociety
DCPD-200900575.scrb            1          1       2         2             4
DCPD-200900595.scrb            1          2       0         7             7
DCPD-200900884.scrb            4          2       0         9             7
DCPD-201000036.scrb            5          1       0         2             2
DCPD-201000130.scrb            1          1       0         1             2
DCPD-201000636.scrb            2          2       0         8             1
                    WorkCareer DropOut Accountability AssessStudent Funding
DCPD-200900575.scrb          7       0              0             0       0
DCPD-200900595.scrb          9       2              0             0       0
DCPD-200900884.scrb         12       0              1             2       0
DCPD-201000036.scrb          5       0              0             0       1
DCPD-201000130.scrb          2       0              0             0       1
DCPD-201000636.scrb         12       0              2             1       0
                    Globalization AllStudents NationInterest ProfDev
DCPD-200900575.scrb             0           0              0       0
DCPD-200900595.scrb             0           0              0       0
DCPD-200900884.scrb             0           0              0       0
DCPD-201000036.scrb             0           0              0       0
DCPD-201000130.scrb             0           0              0       0
DCPD-201000636.scrb             0           0              0       0
                    NationDefense BestFirst AdmissionCollege
DCPD-200900575.scrb             0         0                0
DCPD-200900595.scrb             0         0                0
DCPD-200900884.scrb             0         0                0
DCPD-201000036.scrb             0         0                0
DCPD-201000130.scrb             0         0                0
DCPD-201000636.scrb             0         0                0
#
On 20.10.2011 18:58, Henri-Paul Indiogine wrote:
names.arg = rep(NA, nrow(file.codes))

in that case.

Best,
Uwe Ligges
#
Hi Uwe!

2011/10/20 Uwe Ligges <ligges at statistik.tu-dortmund.de>:
Yes, that works beautifully.  Danke schoen!

Henri-Paul
#
Hi Uwe!

2011/10/20 Uwe Ligges <ligges at statistik.tu-dortmund.de>:
I could not find 'xps',  do you mean 'xpd'?

This is what I have so far:
danke,
Henri-Paul
#
On 20.10.2011 22:29, Henri-Paul Indiogine wrote:
Yes, sorry, a typo.

Best,
Uwe