r - 试图在 R 中的 ggplot 图上获得更平滑的线
问题描述
所以我有一个折线图,我想让它看起来比现在更平滑一些。现在,图表上有一堆锯齿状的边缘,我希望它弯曲一点。我尝试使用 geom_smooth ,但这使得最大的 y 值接近 150,而它应该接近 230(如图所示)。知道如何使这个折线图更平滑一点吗?
library(tidyverse)
library(ggplot2)
library(ggrepel)
library(dplyr)
source("https://raw.githubusercontent.com/samhoppen/2020_FF_Analysis/master/Functions/fpros_scrape_projections.R")
source("https://raw.githubusercontent.com/samhoppen/2020_FF_Analysis/master/Functions/set_vor.R")
position <- c("qb", "rb", "wr", "te")
week <- "draft"
crossing(position, week)
projections <- crossing(position = position, week = week) %>%
pmap_dfr(scrape_projections) %>%
mutate_at(vars(pass_yds, rush_yds, rec_yds), str_remove, ",") %>%
mutate_at(vars(pass_att:rec_tds), as.numeric) %>%
mutate_at(vars(team:position), as.factor) %>%
select(-c("week")) %>%
as_tibble()
default_baseline <- c(QB = 15, RB =72, WR = 90, TE = 30, K = 6)
vor_table <- set_vor(projections,
vor_baseline = default_baseline,
vor_var = "fpts")
ggplot() +
geom_line(data = vor_table,
aes(x = fpts_rank, y = fpts_vor))
解决方案
这可能有效:
ggplot()+
stat_smooth(data = vor_table, aes(x = fpts_rank, y = fpts_vor),
se = F, method = "lm", formula = y ~ poly(x, 10))
推荐阅读
- ssis - SSIS OLE DB 数据源输入
- excel - 在 vb 中使用 Epplus 更改条形图的条形大小
- vba - 使用指定的子字符串将单元格链接到文件名?Excel
- javascript - WTForms-Javascript:将 onclick 传递给 WTF 字段
- html - 尽管 div 被隐藏,但仍宣布 aria-live 文本更改
- angular - Azure Web App wwwroot 在发布时重复
- mysql - azure cloud shell 工作时使用工作台访问 Azure MySQL 数据库
- javascript - Angular 2 Rxjs 在服务器响应后创建动作
- php - Google API + PHP + Ajax 调用 - 请求的资源上存在 Access-Control-Allow-Origin 标头
- python - sys.argv 列表索引超出范围错误