Reputation: 421
I have a dataframe in which I have Recall values for 2 different groups of data. I have made a density plot using below code but I am confused about how it looks. For one group (GE in this case) the recall is very high (always 1), in the plot I anticipate a sharp and comparatively higher peak (w.r.t. Epi group) at x-axis=1 while this is not the case in the output graph (see attached picture).
Command I used:
ggplot(epiGE, aes(x=Rec)) + geom_density(aes(group=Class, colour=Class, fill=Class), alpha=0.3) + theme(axis.title.x=element_blank(), axis.title.y=element_blank())
I have also tried ggplot2 histogram but there as well at x-axis=1 I don't get the right distribution of GE
group, as the barplot shows that values in Epi
group having Recall=1
are more as compared to GE
group.
ggplot(epiGE, aes(x=Rec)) + geom_histogram(aes(group=Class, colour=Class, fill=Class), alpha=0.3) + theme(axis.title.x=element_blank(), axis.title.y=element_blank())
Can somebody please guide me what I am doing wrong here?? Thank you.
Here is my data dput:
> dput(epiGE)
structure(list(Class = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L), .Label = c("Epi", "GE"), class = "factor"),
Rec = c(1, 1, 0.928571428571429, 1, 1, 1, 0.625, 1, 0.935897435897436,
1, 0.911764705882353, 1, 0.790697674418605, 1, 0.891891891891892,
1, 1, 1, 0.98019801980198, 1, 0.949367088607595, 1, 0.877551020408163,
1, 0.944444444444444, 1, 1, 1, 0.955445544554455, 1, 0.5,
1, 0.170731707317073, 1, 0.513513513513513, 1, 0, 1, 0.9,
1, 0.875, 1, 0.884615384615385, 1, 0.5, 1, 0.9, 1)), .Names = c("Class",
"Rec"), class = "data.frame", row.names = c(NA, -48L))
Upvotes: 0
Views: 237
Reputation: 39174
This is related to the bandwidth of smoothing. You can use the adjust
argument to adjust the bandwidth. Here is an example.
ggplot(epiGE, aes(x=Rec)) +
geom_density(aes(group=Class, colour=Class, fill=Class), alpha=0.3, adjust = 1/10) +
theme(axis.title.x=element_blank(), axis.title.y=element_blank())
Set adjust
to 1/10
means using 1/10
of the default bandwidth.
Upvotes: 1