I have a dataset called "merged", which contains 3 numeric columns "pauseMedian" and "numTotalPauses" and "diff". I also have a splineHull dataset, which also contains numeric columns "pauseMedian" and "numTotalPauses", plus a 6-level factor "microstyle"
I have the following code, which works perfectly. It plots a scatter plop and then overlay it with splineHull polygons colored according to "microstyle".
script 1:
ggplot(data=merged,aes(x = pauseMedian, y = numTotalPauses))
+ geom_point()
+ geom_polygon(data = splineHull,
mapping=aes(x=pauseMedian,
y=numTotalPauses,
group=microstyle,
color = microstyle),
alpha=0)
Then, I also want to change the color of the points in the scatter plot by adding just one attribute color = diff.
script 2:
ggplot(data=merged,aes(x = pauseMedian, y = numTotalPauses, color = diff))
+ geom_point()
+ geom_polygon(data = splineHull,
mapping=aes(x=pauseMedian,
y=numTotalPauses,
group=microstyle,
color = microstyle),
alpha=0)
I see the following error:
Error: Discrete value supplied to continuous scale
I don't know why I see this error. If I still want colored scatter plot but no polygons, I run the following code it works again.
script 3:
ggplot(data=merged,aes(x = pauseMedian, y = numTotalPauses, color = diff))
+ geom_point()
So, what happened with script 2, where is the error from, and how can I make it work?
See Question&Answers more detail:
os