How to bring x labels to appear in a barplot?

Hello RStudio Community,

I am working on a barplot. I am unable to bring the x-labels in the x-axis and make the size of x-labels smaller. Following is my code:

fruits <- c(50, 30, 14)
fruit_names <- ("apples", "oranges", "bananas")
barplot(fruits, xlab = fruit_names)

Hoping to hear back.

Thanks,
Tank

Is this what you are looking for?

fruits <- c(50, 30, 14)
fruit_names <- c("apples", "oranges", "bananas")
barplot(fruits, names.arg = fruit_names, cex.names = 0.75)

Thanks FJCC!

This made the xlabels appear on the x-axis.

But my fruit_names is 12 elements long and all of them are not showing up on the x-axis. How can I make all the labels appear under corresponding bars in the bar plot?

I reduced the cex.names factor and was able to get all the x labels on x-axis. Thanks again!

Please post a copy of your data. To do that, you can use the dput function. Post the output of dput(fruits) and dput(fruit_names) and place a line with three back ticks just before and after the pasted output. Like this
```
You pasted output here
```

fruits <- c(50, 30, 14)
fruit_names <- c("apples", "oranges", "bananas")
barplot(fruits, names.arg = fruit_names, cex.names = 0.65)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.