简体   繁体   中英

How to use `key_glyph` with `geom_jitter`?

The following does not add anything to the legend:

ggplot(diamonds, aes(x = color, y = table, color = cut)) + 
  geom_jitter(key_glyph = draw_key_rect)

缺少图例字形的钻石图

draw_key_point works, draw_key_dotplot does to. draw_key_rect also perfectly works with geomtries like geom_line or geom_linerange . How can I use it with points?

Add the aesthetic fill for rect

library(tidyverse)

diamonds %>% 
  ggplot()+
  geom_jitter(aes(x=color, y=table,
                  color=cut,
                  fill=cut),
                  key_glyph = draw_key_rect)

Created on 2020-12-01 by the reprex package (v0.3.0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM