[英]Trying to get a smoother line on a ggplot graph in R
所以我有一個折線圖,我想讓它看起來比現在更平滑一些。 現在,圖表上有一堆鋸齒狀的邊緣,我希望它彎曲一點。 我嘗試使用 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))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.