在处理ggplot()+ geom_dotplot()时,我想知道如何将填充点更改为填充正方形
答案 0 :(得分:0)
欢迎来到stackoverflow。这是一个完全的hack,但是它将做您想要的
# plot just the dotplot
p <-
ggplot(mtcars, aes(x = mpg)) +
geom_dotplot(binwidth = 1.5, dotsize = 1) +
ylim(-0.1, 1.1)
# this is the "instructions" of the plot
gpb <- ggplot_build(p)
# gpb$data is a list, you need to use the first element
gpb$data[[1]] %>%
ggplot(aes(x, stackpos/max(stackpos))) +
geom_point(shape = 22, size = 14, fill = "blue") +
ylim(-0.1, 1.1)