【发布时间】:2019-10-21 10:29:43
【问题描述】:
在处理ggplot()+geom_dotplot()时,想知道如何将实心点改为实心正方形
【问题讨论】:
-
来自
?geom_dotplot: "'geom_dotplot()' 理解以下美学... 'x', 'y', 'alpha', 'color', 'fill', '组'”。看来如果要改变形状,可能需要写一个新函数。
在处理ggplot()+geom_dotplot()时,想知道如何将实心点改为实心正方形
【问题讨论】:
?geom_dotplot: "'geom_dotplot()' 理解以下美学... 'x', 'y', 'alpha', 'color', 'fill', '组'”。看来如果要改变形状,可能需要写一个新函数。
欢迎来到stackoverflow。这是一个完全的黑客,但它会做你想做的事
# 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)
【讨论】: