Skip to content

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

@chenjy327

Description

@chenjy327

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions