how to create a plot with customized points in R?

后端 未结 2 1572
执笔经年
执笔经年 2020-12-10 08:55

I know I can create a plot with line and dots using the type = \"o\" argument in the plot command. I would like some more control over this -- I want to be able to draw the

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-10 09:44

    You could use layering (I don't work in base too much any more as a social researcher I love the facet_grid of ggplot, so there may be a better way) as in:

    x <- sort(rnorm(25))
    y <- sort(rnorm(25))
    z <- as.factor(sample(LETTERS[1:5], 25, r=TRUE))
    
    plot(x, y, pch = 19, cex = 1.3)
    par(new = TRUE)
    plot(x, y, pch = 19, cex = 1, col = z)
    

    Which gives you: enter image description here

提交回复
热议问题