Cris
Cris

Reputation: 65

How can I make a bar plot using many names in x axis in R?

I have a simple question. I need make a bar plot for c using a limit (0.4 to 1.0) and I need all the names in the x-axis(1- 100).

  name=seq(1:1000)
  c=runif(1000,0.4,1.0)
  c=round(c,2)

How can I do that? I tried just

     barplot(c,names.arg=name, ylim=c(0.4,1.0))

Thank you

Upvotes: 0

Views: 263

Answers (1)

joran
joran

Reputation: 173517

For an example of how to make the x axis labels at least visible, while restricting the y axis, consider doing something like this:

barplot(c - 0.4,names.arg=name,axes = FALSE)
axis(side = 2,at = seq(0,0.6,by = 0.2),labels = as.character(seq(0.4,1.0,by = 0.2)))

But note that:

  1. You shouldn't name variables c, it's confusing.
  2. You really aren't going to fit 1000 labels under there. You figure at at least 15-20 pixels for each number, even if turned vertically, times 1000 and you've got yourself a very large image.

You should rethink whether a visualization like this is really meaningful.

Upvotes: 1

Related Questions