I have to plot categorical variable flag
having values Y
and N
against continuous variable Weight
. Which is best kind of plot?
qplot(x=Data$Weight, geom="histogram", main = "Weight distribution for Y Goods", binwidth = 0.5, xlab = "Weight of Y Goods", fill=I("blue"), col=I("red"), alpha=I(0.2), xlim=c(0,5))
try adding fill = Data$Buy_Flag
so your plot code looks like this:
qplot(
x = Data$Weight,
fill = Data$Buy_Flag,
geom = "histogram",
main = "Weight distribution for Y Goods",
binwidth = 0.5,
xlab = "Weight of Y Goods",
fill = I("blue"),
col = I("red"),
alpha = I(0.2),
xlim = c(0, 5)
)
and your graph looks like this:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.