0

所以我有一个看起来像的喷雾图 在此处输入图像描述

线方程:

left <- function(x) {-1*x}
left_mid <- function(x) {-2.5*x}
mid <- function(x) {-99*x}
right <- function(x) {1*x}
right_mid <- function(x) {2.5*x}

我有每个点的 x,y 坐标以及每个区域中命中的百分比。我想在每个区域着色(比如红色代表较高的百分比,蓝色代表较低的百分比),我对 geom_ribbon 有点困惑,我认为这是必要的:

这是情节的代码:

mlb + geom_point(data = data, aes(x = x, y = y, color = spray)) + xlim(-230,300) + ggtitle("Spray Chart") +
  stat_function(fun = left_mid, size = 2, color = "red") + stat_function(fun = mid, size = 2, color = "red") + 
  stat_function(fun = right_mid, size = 2, color = "red") + stat_function(fun = right, size = 2, color = "red") + 
  xlim(-200,200) + ylim(-10,410) + stat_function(fun = left, size = 2, color = "red")

哦,mlb 只是情节照片

4

0 回答 0