I want to arrange my data in one category along the X axis, but in a different way, as in this example:
Chart 1 without coloring:
require(ggplot2) nocolor <- ggplot(mtcars, aes(x=as.factor(cyl), y=disp)) + geom_dotplot(binaxis="y", stackdir = "center") print(nocolor)
Chart 2 with coloring:
nododge <- ggplot(mtcars, aes(x=as.factor(cyl), y=disp, fill=as.factor(gear))) + geom_dotplot(binaxis="y", stackdir = "center") print(nododge)
One of the problems that occurs after the introduction of color, is that the points belonging to different groups will no longer deviate from each other. This causes problems with my real data, as I get points that have the same meaning and completely hide each other.
Then I tried this, but it distorted my data:
Chart 3:
garbled <- ggplot(mtcars, aes(x=as.factor(cyl), y=disp)) + geom_dotplot(binaxis="y", stackdir = "center", fill=as.factor(mtcars$gear)) print(garbled)
The points deviate from each other, but the coloring is just random and not true.
I was expecting an answer to this question to solve my problem, but the coloration remained random:
Chart 4:
graphdata <- mtcars graphdata$colorname <- as.factor(graphdata$gear) levels(graphdata$colorname) <- c("red", "blue", "black") jalapic <- ggplot(graphdata, aes(x=as.factor(cyl), y=disp)) + geom_dotplot(binaxis="y", stackdir = "center", fill=as.character(graphdata$colorname)) print(jalapic)
Does anyone have an idea how to get points on graph number 2 in order to avoid each other, or how to fix the coloring on graphs 3 or 4? I would really appreciate any help, thanks.