如何更改R中geom_dotplot中点的形状? [英] How to change the shape of dot in geom_dotplot in R?

查看:69
本文介绍了如何更改R中geom_dotplot中点的形状?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在处理 ggplot()+geom_dotplot() 时,我想知道如何将填充的点更改为填充的正方形

when working on ggplot()+geom_dotplot(), I wonder how to change the filled dot to the filled square

推荐答案

欢迎使用 stackoverflow.这是一个彻头彻尾的黑客,但它会做你想做的

Welcome to stackoverflow. This is a total hack, but it will do what you want

# 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)

这篇关于如何更改R中geom_dotplot中点的形状?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆