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 with Comma

20200428

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

ds %>%
  ggplot(aes(wind_dir_9am, fill=wind_dir_9am)) +
  geom_bar() +
  scale_y_continuous(labels=comma) +
  theme(legend.position="none") +
  labs(x=vnames["wind_dir_9am"], y="Count")

With ggplot2 Version 0.9.0 the scales package introduced a mechanism to handle many of the scale operations, in such a way as to support base and lattice graphics, as well as ggplot2 graphics. Scale operations include position guides, as in the axes, and aesthetic guides, as in the legend.

The function scales::comma() is useful for presenting numbers using commas to separate the thousands. This is always a good idea as it assists the reader in quickly determining the magnitude of the numbers we are looking at. As a matter of course, I recommend commas in plots (and tables) at all times. To do so use scale_y_continuous() with labels=comma.


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.