r - How to adjust the labels on ggplot2 line graph to show the group, and add space -
i have following data table:
gin <- c("a_1","a_2","a_3","a_4","b_1","b_2","b_3","b_4","b_5","c_1","c_2","c_3") bc <- c(1219.79, 1486.84, 1255.80, 941.87, 588.19, 304.02, 279.71, 373.40, 179.89, 385.02, 218.76, 423.33) group <- c("a","a","a","a","b","b","b","b","b","c","c","c") ex <- data.frame("gin" = gin, "bc" = bc, "group" = group)
i have 2 issues:
(a) x-axis labels read value "group", not "gin'. also,
(b) increase spacing between adjacent groups. a, b, , c close make larger graphs difficult on eye.
the line here:
ggplot(data=ex, aes(x=gin, y=bc, group=group)) + geom_line() + geom_point() + theme(axis.text.x = element_text(angle = 90, hjust = 1))
produces plot:
user4968354 suggested facet, , came this. pretty looking for:
ggplot(data=ex) + geom_line(aes(x=gin, y=bc,group=group)) + geom_point(aes(x=gin, y=bc)) + facet_grid(. ~group, scales="free")
cheers.
Comments
Post a Comment