I am trying to make a simple barplot but i have a problem that I have duplicated names on x-axis. So when ever I am trying to write names on x-axis it does not show complete string. I have following data
x <- c(1.8405917,0.3265986,1.5723623,464.7370299,0.0000000,3.2235716,
3.1223534, 7.0999787, 1.7122258,3.2005524,3.7531266,469.4436828)
and I am using barplot
barplot(x,xlab=c("AA/AA","AA/CC","AA/AC","AA/NC","CC/AA","CC/CC","CC/AC",
"CC/NC","AC/AA","AC/CC","AC/AC","AC/NC"))
But it does not work. I also used
axis()
But it does not work as well.
Thanks in advance.
No,
xlabis for providing a label for the entire x-axis of the plot, not for labelling the individual bars.barplot()takes the labels for the bars from the names of the vector plotted (or something that can be derived into a set of names).Edit: As @Aaron mentions,
barplot()also has anames.argto supply the labels for the bars. This is what?barplothas to say:Which explains the default behaviour if
names.argis not supplied – which is to take the names from the object plotted. Which usage is most useful for you will mainly be a matter of taste. Not having the row/column/names might speed code up slightly, but many of R’s functions will take thenamesattribute (or similar, e.g. row names) directly from objects so you don’t have to keep providing labels for plotting/labelling of results etc.