Как изменить форму точки в geom_dotplot в R? - PullRequest
1 голос
/ 06 июня 2019

при работе с ggplot () + geom_dotplot (), мне интересно, как изменить заполненную точку на заполненный квадрат

1 Ответ

0 голосов
/ 07 июня 2019

Добро пожаловать в 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)

enter image description here

...