-3

I'm using this link to create the circle: Draw a circle with ggplot2

However, when I try to add my next ggplot which uses data from a CSV, I get two separate graphs. I'd like to have the circle overlay the scatterplot.

ggplot(CSV1, aes(x= Pos.X..µm., y = Pos.Y..µm.)) +
    geom_point() 

ggplot(dat, aes(x,y)) + geom_path()  

Thanks!

Matthew
  • 1
  • 1
  • 3
  • 4
    Please provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data. Show the code you tried. Perhaps we can point out the problem. – MrFlick Nov 01 '17 at 19:08
  • ggplot(CSV1, aes(x= Pos.X..µm., y = Pos.Y..µm. )) + geom_point() ggplot(dat,aes(x,y)) + geom_path() – Matthew Nov 01 '17 at 19:13
  • You should edit that into your question rather than leaving as a comment. – MrFlick Nov 01 '17 at 19:14
  • @MrFlick thanks for the tip, I'm new to StackOverflow! – Matthew Nov 01 '17 at 19:19

1 Answers1

1

You just need to combine it into a single object.

ggplot(CSV1, aes(x= Pos.X..µm., y = Pos.Y..µm.)) +
    geom_point()  +
    geom_path(aes(x,y), data=dat)  
MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • It's still only displaying the scatter plot. – Matthew Nov 01 '17 at 19:58
  • 1
    Well then you need to post sample data so we can see what's actually in `CSV1` and `dat` so we can test it ourselves. – MrFlick Nov 01 '17 at 20:00
  • I'm simply reading X & Y position from the .csv but I'd like to overlay a circle. Any suggestions on how to do that? Maybe, there's a better approach than the code I found on the internet. Thanks for your help! – Matthew Nov 01 '17 at 20:02