Warm tip: This article is reproduced from serverfault.com, please click

其他-R ggplot2 geom_point形状

(其他 - R ggplot2 geom_point shapes)

发布于 2020-12-15 10:35:20

我正在与我合作,ggplot2并希望我geom_points根据数据框行设置单独的形状。

data <- read.csv(my_csv_path) # 
plot <- ggplot(data = data) + # in this file I have shape numbers (17 or 21) for each csv row.
 geom_point(aes(shape = shape), color = "grey20")

每行都有各自的形状,我想以此为基础进行绘制。我的输出始终基于csv文件绘制三角形。

有任何想法吗 ?

谢谢 !

Questioner
varguy
Viewed
11
Andrew Baxter 2020-12-15 21:29:13

希望这可以处理你的数据。如果不是,请使用粘贴数据样本dputscale_shape_identity应用数据框中的形状编号:

library(ggplot2)
library(dplyr)

tibble(shape = 1:5, x = 1:5, y = 1) %>% 
  ggplot(aes(x, y, shape = shape)) +
  geom_point(size = 10, colour = "grey20") +
  scale_shape_identity()

reprex软件包(v0.3.0)创建于2020-12-15