1

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

sample data picture

Here is the result. We need labels for all columns to be visible

The bar chart looks good but you cannot see the column name for all 9 levels

Dharman
  • 30,962
  • 25
  • 85
  • 135
lhc0003
  • 49
  • 4
  • 1
    Could you please share your data using `dput(df)`? So we can help you better. – Quinten Apr 07 '22 at 17:38
  • just added a screenshot of the data. The output of dput(df) is way too large – lhc0003 Apr 07 '22 at 17:53
  • Does this answer your question: [How to make font size variables in x axis smaller](https://stackoverflow.com/questions/27367231/how-to-make-font-size-variables-in-x-axis-smaller) – stefan Apr 07 '22 at 17:54

1 Answers1

1

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:

enter image description here

Rotating x-axis labels:

plot <- barplot(sort(table(df$Department_lower), decreasing=TRUE), las = 2)

Output:

enter image description here

Quinten
  • 35,235
  • 5
  • 20
  • 53
  • @Ihc0003, No problem. Check this post for more options: https://stackoverflow.com/questions/9981929/how-to-display-all-x-labels-in-r-barplot – Quinten Apr 07 '22 at 18:05