0

I have a dataset that looks like that, I want to plot the exact same bar plot in R.

https://i.stack.imgur.com/0OSqo.png

This is what I've been trying:

barplot(as.matrix(table[,2:8]), beside = T, ylim= c(0,1),
        col = c("red", "blue", "green", "yellow", 
                "orange", "purple", "cyan", "grey", 
                "deeppink", "red4", "black", "brown"))

I get a bar plot, but now when I want to change the labels instead of a,b,c...g to this:

(-0.20,-0.15) 
(-0.15,-0.10)
.
.
.
(0.20,0.25)

I get an X character in front of every label I was trying to write:

https://i.stack.imgur.com/UkUXI.png

Thank you.

Sven Hohenstein
  • 80,497
  • 17
  • 145
  • 168
JM88
  • 457
  • 3
  • 6
  • 11
  • 1
    Hi and welcome to SO! It is much easier to help you if you provide a small sample of your data. [**See here on how to easily create a minimal, reproducible example**](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). Thanks. – Henrik Nov 29 '13 at 16:07
  • Show the whole function that you used to change the labels. It's likely the source of the problem. – TWL Nov 29 '13 at 16:15
  • It sounds as though you might have tried to change then ames of the dataframe named 'table'. – IRTFM Nov 29 '13 at 16:35
  • Hi, thanks for the reply. I didn't know how to change them in R, so I opened my data in a textedit and change the names of the variables there, but i got that strange result – JM88 Nov 29 '13 at 17:52
  • I suppose `table` is your data table. If you type `str(table)` at the command line and then post the output as an edit to your question, you are much more likely to get help. – jlhoward Nov 29 '13 at 18:40
  • 1
    A great resource when you want a graph that "looks like this other graph" is the [chart chooser](http://www.yaksis.com/posts/r-chart-chooser.html). Yours is the "column chart". Click on the name and it will give you example code. – nacnudus Nov 29 '13 at 21:08
  • Note that @nacnudus URL will give you example using `ggplot2` - as I commented in your other post this package is much more powerful than R's standard plot function. – CMichael Jan 17 '14 at 14:51

0 Answers0