I'm using ggplot2 in R and have been having trouble with a scatter plot using geom_point. I have the basic x, y scatter plot but attempted to color points according to another variable: EVENT. EVENT is either "wet" or "dry". I tried changing EVENT to a factor since it's just two levels, but that didn't change anything. The plot seems to be shrunk horizontally. I can get a "normal" plot if I switch EVENT with a continuous variable, but get a shrunken plot when I enter factors or categorical. Here is my code and plot.
ggplot(data=mydata, aes(x=conversion.ratio, y=sampler.purchaser.ratio)) +
geom_point(alpha=.5, aes(color=EVENT.WET.DRY))`
Any ideas? Am I missing something? I tried making a reproducible example:
EVENT.WET.DRY<-c(rep("Dry",7),rep("Wet",18))
conversion.ratio=rnorm(25,.5,.1)
sampler.purchaser.ratio=rnorm(25,.7,.05)
mydata<-data.frame(factor(EVENT.WET.DRY), conversion.ratio, sampler.purchaser.ratio)
ggplot(data=mydata, aes(x=conversion.ratio, y=sampler.purchaser.ratio)) +
geom_point(aes(color=EVENT.WET.DRY))
This plots fine, however. What it is is something to do with the variable EVENT.WET.DRY within the original data set. I've already had some issues with it because it was originally a SAS file that was transferred to an SPSS file that I am bringing into R.