GuangchuangYu / ggplotify

ggplot everything
https://cran.r-project.org/package=ggplotify/vignettes/ggplotify.html
105 stars 11 forks source link

The coordinate positions difference between points() and geom_point() #10

Open chenjy327 opened 4 years ago

chenjy327 commented 4 years ago

Hi: When i was using as.ggplot() convert points() to ggplot objects, then add some points with geom_point() in the plots, i found that the points drawn using points() and geom_point() are in different positions.

Here is my code:

plot_f <- function(){
          plot.new()
          points(df[, 1:2], cex=0.6, col=2, pch=2)
       }
 p <- as.ggplot(
          ~plot_f()
       )

  p <- p +
          geom_point(
         data = df,
         aes(x = df[,1], y = df[,2]),
          size = 4
        )

df is a data frame : 微信图片_20201006110053

the result p is: 微信图片_20201006110046

Could you tell how to solve the problem?

Thanks!