Go to TogaWare.com Home Page. Data Science Desktop Survival Guide
by Graham Williams
Duck Duck Go



CLICK HERE TO VISIT THE UPDATED SURVIVAL GUIDE

Labels Rotated

20200428

\includegraphics[width=\textwidth]{figures/onepager/ggplot2:mean_temp3pm_location_rotated_labels-1}

ds %>%
  ggplot(aes(x=location, y=temp_3pm, fill=location)) +
  stat_summary(fun="mean", geom="bar") +
  labs(x=vnames["location"],
       y=glue('Mean {vnames["temp_3pm"]}')) +
  theme(legend.position="none",
        axis.text.x=element_text(angle=45, hjust=1, size=6))

When a bar chart has many bars and non-trivial labels then it is useful to rotate the labels. Here we plot the mean temperature at 3pm for each location in the dataset. Without rotating the x-axis labels (the locations) the x-axis will be blighted with much overlapping. Labels can be rotated using a ggplot2::theme() option of axis.text.x= with angle=$45^\circ$. Use hjust=1 to align the labels appropriately.


Support further development by purchasing the PDF version of the book.
Other online resources include the GNU/Linux Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 2000-2020 Togaware Pty Ltd. . Creative Commons ShareAlike V4.