Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ggplot may display decimal values in the legend when the column contains numerical values because it is default behavior to display the actual values in the legend. To change this behavior, you can use the scale_*_format() function to format the legend labels to display as desired, such as removing decimal points or rounding to a specific number of digits. For example, using scale_fill_continuous() with the labels = scales::comma_format() argument will format the legend labels with comma separators.