So the parabola plot needs to be rescaled (since it goes to 100 and no point is > 4) and then you just want it overlaid on the scatterplot. No additional bells or whistles. So kind of like when you add abline to a plot?
So I've been trying to figure this one out for a while and I haven't been able to.
I have this nice scatterplot
That gives me this nice graphCode:x1 <- rnorm(200, 3, .28) y1 <- rnorm(200, 3, .28) data <- data.frame(x = c(x1), y = c(y1)) ggplot(data, aes(x=x, y=y)) + geom_point()
I also have this nice quadratic function
That gives me this nice graphCode:fun.1 <- function(x) x^2 + 2 p1 <- ggplot(data = data.frame(x = 0), mapping = aes(x = x)) p1 + stat_function(fun = fun.1) + xlim(-10,10)+ ylim(-3, 100)
What I'm trying to figure out here is how to overlay the two. So that the points are contained within the parabola (or outside of it if that's the case).
Any ideas?
for all your psychometric needs! https://psychometroscar.wordpress.com/about/
So the parabola plot needs to be rescaled (since it goes to 100 and no point is > 4) and then you just want it overlaid on the scatterplot. No additional bells or whistles. So kind of like when you add abline to a plot?
Stop cowardice, ban guns!
Yup. It's pretty straightforward but I can't seem to find any examples online where the curve is not estimated or fitted from the data itself. And here I have two things going on, the basic scatterplot that just shows the relation between X and Y and a theoretical curve, my parabola, that I wanna show with the points inside of it.
for all your psychometric needs! https://psychometroscar.wordpress.com/about/
So.... yeah. Spunky would like to apologize for creating garbage posts on the internet. Apparently, what I was originally trying was correct but I sort of forgot that ggplot2 pushes sections of the plot outside of the viewable area unless the scaling is done right.
SO, if you do something simple like this:
You get something like thisCode:fun.1 <- function(x) x^2-30 x1 <- rnorm(200, 5, 10) y1 <- rnorm(200, 5, 10) data <- data.frame(x = c(x1), y = c(y1)) p11<-ggplot(data, aes(x=x, y=y)) + geom_point() p11 + stat_function(fun = fun.1) + xlim(-10,10)+ ylim(-30,100)
Which is kind of what I was looking for
for all your psychometric needs! https://psychometroscar.wordpress.com/about/
What is the plot for? It looks pretty pointless or bent
Stop cowardice, ban guns!
Tweet |