The points data has information from all three groups of the id variable but the rectangle, based on the box dataset, is for only a single group. The following example is based on this Stack Overflow question. For example, this can be useful when different layers are based on a different number of levels for the same grouping factor. Removing aesthetic for only some parts of the legend is another use for override.aes. Suppress aesthetics from part of the legend Guides(color = guide_legend(override.aes = list(size = 3) ) ) ggplot(data = diamonds, aes(x = carat, y = price, color = cut) ) + To increase the size of the points in the color legend of my plot, the layer I’ll add will look like: guides(color = guide_legend(override.aes = list(size = 3) ) )Īdding this layer to the initial plot, you can see how the points in the legend get larger while the points in the plot remain unchanged. The override.aes argument takes a list of aesthetic parameters that will override the default legend appearance. Override.aes is an argument within guide_legend(), so if you’re looking for more background you can start at ?guide_legend. I am going to change the legend for the color scale, so I’ll use color = guide_legend() as the scale name-guide pair. The guides() function uses scale name-guide pairs. One way to do this is by adding a guides() layer. This is a case where I’d want to make the legend more readable by increasing the point size and/or reducing the point transparency. Making the points small and transparent may be desirable when plotting many points, but it also makes the legend more difficult to read.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |