添加黑色轮廓geom_point并填充与其他变量不同的自变量

时间:2020-05-05 13:00:24

标签: r ggplot2

  1. 如何为所有点添加黑色轮廓? ->我尝试过: geom_point(aes(size = scaled_val, colour = value), colour "black")-但这会使填充物变黑。我也尝试添加另一个:geom_point(colour= "black"),但它在缩放的点上绘制了黑点

  2. 我可以忽略其中一个变量的按颜色显示的颜色吗? (即:我希望变量C像原样那样按比例绘制大小,但是忽略按值着色并具有独立的颜色(黑色))

data <- tibble::tibble(
  value = c(4.07, 5.76, 2.87,4.94,5.48, 6.75,1.53,1.35, 1.32), 
  Variable = rep(c(rep("A",3),rep("B",3), rep("C",3))),
  Experiment = rep(c(1:3),3))

data <- data %>%group_by(Variable)%>%
  mutate(scaled_val = scale(value)) %>%
  ungroup()

data$Variable <- factor(data$Variable,levels=rev(unique(data$Variable)))

ggplot(data, aes(x = Experiment, y = Variable, label=NA)) +
  geom_point(aes(size = scaled_val, colour = value)) + 
  geom_text(hjust = 1, size = 2) +
  theme_bw()+
  scale_color_gradient(low = "lightblue", high = "darkblue")+
  scale_x_discrete(expand=c(1,0))+
  coord_fixed(ratio=4)

enter image description here

谢谢!

0 个答案:

没有答案