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?

color=difftogeom_point(aes(color=diff))?fill = microstylefor polygondput(merged[sample(1:nrow(merged),20),]). That will give 20 randomly selected rows of your data (do the same for splineHull).geom_polygonandgeom_point, I getError: Continuous value supplied to discrete scale. There seems to be a conflict between the color scales of the two geoms, one being discrete, the other being continuous, but I'm not sure why that's happening. I would have thought having two separate geoms would result in two separate colour scales.