0

I want to make sure this output's x-axis is readable or make it bigger. I have tried coord_flip and did not work

electric_cons %>%
  group_by(day_of_week, Hour) %>%
  summarise(AvgUnits = mean(Unit)) %>%
  ggplot() + 
  geom_bar(aes(x = Hour, y = AvgUnits, fill = AvgUnits), stat = "identity") + 
  facet_wrap(.~day_of_week) + 
  theme(axis.text.x = element_text(angle=90, vjust=1, hjust=1)) + 
  ggtitle("Average Consumption of electricity during a day", subtitle = "Consumption recorded in every 30 minutes - Weekly ") + 
  xlab("Time") + 
  ylab("Average units consumed")

img

camille
  • 16,432
  • 18
  • 38
  • 60
  • 3
    Welcome to SO, Thiri Jeyaseelan! It's difficult to help without knowing what your data looks like. Most questions on SO greatly benefit from being *reproducible*, including unambiguous sample data in addition to the code you've provided. Please [edit] your question and add the output from `dput(head(electric_cons,20))`. Other discussions about reproducible questions include https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info, and I encourage you to skim through them. Thanks! – r2evans Sep 20 '21 at 19:14
  • In general, you can either give the axis more space (e.g. by using `facet_wrap(.~day_of_week, ncol = 1)` to give each day the full width), or by showing fewer labels (e.g. using `scale_x_continuous(breaks = [something with fewer breaks]`). I think any solution will have to include at least one of those approaches. – Jon Spring Sep 20 '21 at 21:52

0 Answers0