Could anyone make me understand what that line of code means in simple words? Thanks

guides(fill = guide_legend(reverse = TRUE))

Assuming that you're referring to the legend in ggplot2. This is just reversing the order of the legend. See the last example:

1 Like

What is the purpose of guides function and why do we put guide_legend inside the function for fill?

Additional adjustments for the legend, I guess.

fill (instead of col) is in there as it is the type of graph you are using.

The guides (the axes and legends) help readers interpret your plots. Guides are mostly controlled via the scale (e.g. with the limits , breaks , and labels arguments), but sometimes you will need additional control over guide appearance. Use guides() or the guide argument to individual scales along with guide_colourbar() or guide_legend() .

From here: Function reference • ggplot2

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.