Reputation: 49
Here is the code that I used to create the table
barplot(sort(table(df$Department_lower), decreasing=TRUE))
Here is a sample of the table data
Here is the result. We need labels for all columns to be visible
Upvotes: 1
Views: 510
Reputation: 41603
An option would be rotation the labels of your x-axis using las = 2
. I created some extra random labels to give you a reproducible example. First a before plot:
df <- data.frame(Department_lower=sample(c('labelA', 'entrees', 'salad', 'labelB', 'general', 'catering', 'swag', 'labelC', 'labelD'),
50, replace=TRUE))
plot <- barplot(sort(table(df$Department_lower), decreasing=TRUE))
Before:
Rotating x-axis labels:
plot <- barplot(sort(table(df$Department_lower), decreasing=TRUE), las = 2)
Output:
Upvotes: 1