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.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-09-27 11:00:00 +0000
Seen: 11 times
Last updated: Mar 12 '22
How can a name be extracted from a variable in a dynamic manner?
What is the technique for organizing a list that contains a mixture of Tree Objects and Tuples?
Is there a %n% function available in R, and if yes, which package contains it?
Determine whether all elements from one Vec are included in another Vec.
Can the contains any function be applied in a grouped query?
What is the method of inserting y-axis labels into a coord_polar chart in ggplot?
What is the method for merging two plots in R studio with ggplot?