R 如何在ggplot2中的自定义绘图上绘制图形?

R 如何在ggplot2中的自定义绘图上绘制图形?,r,ggplot2,plot,R,Ggplot2,Plot,我正在使用从以下站点获得的地块: 我不知道如何在这上面画点。我该怎么做呢? 所以没有尝试过任何东西;»那么,就这样做:试试!你不能失败 base.football + geom_point(aes(1:10, seq(1, 100, 10)), color = "red") + geom_point(aes(0, 50), color = "blue") 资料 库(ggplot2) 你必须清楚地解释你想画的点和地点。否则,一旦你说你想要别的东西,我们就需要多次修改我们的答

我正在使用从以下站点获得的地块: 我不知道如何在这上面画点。我该怎么做呢?

所以没有尝试过任何东西;»那么,就这样做:试试!你不能失败

base.football + 
    geom_point(aes(1:10, seq(1, 100, 10)), color = "red") + 
    geom_point(aes(0, 50), color = "blue")

资料
库(ggplot2)

你必须清楚地解释你想画的点和地点。否则,一旦你说你想要别的东西,我们就需要多次修改我们的答案。还有,你试过什么?关于我想画的东西,比如我想画(0,0),并让它位于场的中心。我不知道从哪里开始,因此没有尝试过任何东西中心的一个点是
geom_点(data=data.frame(x=0,y=50),aes(x=x,y=y))
。那么就这些了?@arnavharkenavy我刚看了你最后的帖子。你似乎在努力学习R的基础知识。在开始学习更高级的东西之前,也许可以尝试一门课程来强化你的技能?作为第一步,我非常推荐Coursera上的“R编程”。
library(ggplot2)
theme.football <- function(){
    theme(panel.grid.minor = element_blank(), 
          axis.text.y = element_text(angle=270, hjust=0.5), 
          panel.border = element_blank(), 
          panel.grid.major = element_line(size = 0.5, linetype = 'solid',
                                          colour = "black"), 
          axis.ticks = element_blank()) 
}

xlim <- (160/3)/2
hash.width <- 3.3
hash.x <- (xlim + hash.width)/2

df.hash <- expand.grid(x = c(-1*xlim, -1*hash.width, hash.width, xlim), y = (0:100))
df.hash <- df.hash %>% filter(!(floor(y %% 5) == 0))
base.football <- ggplot() + xlab("") + ylab("") + 
    theme_minimal() +
    annotate("segment", x = c(-1*xlim, -1*xlim, xlim, xlim), 
             y = c(-10, 110, 110, -10), 
             xend = c(-1*xlim, xlim, xlim, -1*xlim), 
             yend = c(110, 110, -10, -10), colour = "black") + 
    #geom_point(data = df.hash, aes(x, y), pch = 1) + 
    annotate("text", x = df.hash$x[df.hash$x < 0], y = df.hash$y[df.hash$x < 0], label = "_", hjust = 0, vjust = -0.2) + 
    annotate("text", x = df.hash$x[df.hash$x > 0], y = df.hash$y[df.hash$x > 0], label = "_", hjust = 1, vjust = -0.2) + 
    annotate("segment", x = rep(-1*xlim, 21), 
             y = seq(0, 100, by = 5), 
             xend =  rep(xlim, 21), 
             yend = seq(0, 100, by = 5)) +
    annotate("text", x = rep(-1*hash.x, 11), y = seq(0, 100, by = 10), 
             label = c("G   ", seq(10, 50, by = 10), rev(seq(10, 40, by = 10)), "   G"), 
             angle = 270, size = 4) + 
    annotate("text", x = rep(hash.x, 11), y = seq(0, 100, by = 10), 
             label = c("   G", seq(10, 50, by = 10), rev(seq(10, 40, by = 10)), "G   "), 
             angle = 90, size = 4) + 
    scale_y_continuous("", breaks = NULL, lim = c(-10, 110)) + 
    scale_x_continuous("", breaks = NULL, lim = c(-1*xlim, xlim)) + 
    annotate("rect", xmin=-1*xlim, xmax=xlim, ymin=-10, ymax=110, fill="palegreen", alpha=0.1)  + 
    theme.football()