簡體   English   中英

ggplot2 中的填充顏色和白色邊框 geom_points?

[英]Filled colour and white border geom_points in ggplot2?

如何更改點,使其內部充滿顏色(根據因素)但外部有白色邊框? 我找不到標准pch圖的示例

library(data.table)
A = data.table(x = 1:4, y = 1:4, z = c('A','A','B','B'))

ggplot(A) + geom_point(aes(x = x, y = y, color = z)) + facet_grid(~z) + theme_bw()

您正在尋找的形狀是shape=21 然后將你的因素映射到fill aes 並將輪廓的顏色設置為參數:

注意:我已將 reprex 的顏色設置為黑色,因為白色並不真正可見。

library(ggplot2)
A <- data.frame(x = 1:4, y = 1:4, z = c("A", "A", "B", "B"))

ggplot(A) +
  geom_point(aes(x = x, y = y, fill = z), shape = 21, color = "black", size = 5, stroke = 1) +
  facet_grid(~z) +
  theme_bw()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM