r - R ggplot2 geom_point 形状
问题描述
我正在使用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 文件绘制三角形。
有任何想法吗 ?
谢谢 !
解决方案
希望这将适用于您的数据。如果没有,请使用 粘贴数据样本dput
。scale_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 包于 2020-12-15 创建(v0.3.0)
推荐阅读
- python - 为 PyPi 包配置 setup.py
- python - 从 Django 在另一个数据库中重新创建表
- java - Files.walkFileTree 与 Files.walk 在 Windows NTFS 上的性能
- deep-learning - 变压器模型在 Pytorch 中输出 Nan 值
- php - 隐藏目录中的文件
- javascript - 在屏幕捕获 api 中达到大小限制 (5 mb) 时上传 blob
- pycharm - pyplot 某些图像未显示在 PyCharm 的 SciView 选项卡中
- flutter - 孩子:CupertinoAlertDialog 颤振错误
- python - 为 API 获取请求创建 HMAC-SHA1 base 64 签名
- node.js - 如何解决异步回调的笑话测试用例中的异步超时?