r - ggplot add extra x axis on string categorical x -
i use ggplot draw above graph. related code here:
p <- ggplot(avg.dice, aes(x=type, y=average)) + theme_bw() + geom_point() + geom_point(aes(x=type, y=cc.average), col="red") + geom_errorbar(aes(ymin=ci.lower, ymax=ci.upper))
my avg.dice data frame looks this:
type average ci.lower ci.upper cc.average 1 e70 0.6105000 0.525 0.6850000 0.520 2 e89 0.5328000 0.480 0.6100000 0.510 3 f10 0.5902000 0.500 0.6900000 0.490 4 f15 0.4122000 0.365 0.4750000 0.335 5 f20 0.5583000 0.485 0.6200000 0.555 6 f22 0.4332000 0.365 0.4950000 0.325 7 f48 0.3113333 0.200 0.4666667 0.155 8 f80 0.5882000 0.510 0.6900000 0.355 9 i3i8 0.5438000 0.495 0.5900000 0.370 10 m5 0.5986000 0.550 0.6550000 0.485 11 series6 0.5271000 0.470 0.6000000 0.350 12 series7 0.5180000 0.450 0.5850000 0.390 13 x3 0.6190000 0.565 0.6850000 0.645 14 z4e85 0.5340000 0.485 0.6100000 0.505
so x axis automatically show type name in string. how add x axis below current plot can show numeric values related each type? looks graph below:
previously used x axis:
fractions = c(0.22,0.14,0.13,0.12,0.117,0.116,0.112, 0.09, 0.07,0.05,0.037,0.014,0.013,0.009) axis(1,at=1:14,labels=fractions,line=4.5,las=2) mtext("document\n fraction\n in cc",side=1,line=5,adj=-0.09)
but won't work in ggplot, telling me "plot.new has not been called yet"
Comments
Post a Comment