[R] Need data labels to jitter with datapoints in boxplot
smheas
sheasley at aegonusa.com
Thu Sep 17 17:20:33 CEST 2015
Hello, I have created a boxplot with the data points overlayed on top using
the below code. I am happy with the way the datapoints are jittered, however
I cannot figure out how to get the labels to jitter along with the
datapoints. The labels remain in the center and are unreadable. I have tried
a lot of different ways to get them to jitter but can't seem to make it
work. I have also tried making the label font smaller, but they still
overlap too much. Note I cannot use the method of assigning the lcoation of
each label - there are too many and this graph will be updated frequently
with new data. I greatly appreciate your help. Thanks.
After reading in data...
#load packages
library(ggplot2)
#change letter to factor
df$Letter<-as.factor(df$Letter)
#create boxplot
plot<-qplot(Letter,Number,data=df,geom=c("boxplot","jitter"),fill=Letter)
#Add formatting
plot<-plot + geom_text(aes(label=Identifier),size=3)
ggsave(filename="Spreads Plot.pdf",plot=plot,width=11,height=8,units="in")
Result:
<http://r.789695.n4.nabble.com/file/n4712380/PostPic.png>
Sample Data:
Identifier Letter Number
AB AA- 46.74
BC A 59.62
CD A 61.63
DE A 69.49
EF A+ 69.73
FG A+ 74.57
GH A 75.01
HI A 77.52
IJ A 77.52
JK A 80.12
KL A 80.14
LM A- 80.35
MN A 81.98
NO A- 82.72
OP A+ 83.56
PQ A 85.29
QR A- 85.46
RS A- 85.92
ST A 86.11
TU A- 86.55
UV A 86.57
VW A 88.32
WX A 89.4
XY A- 96.81
YZ A+ 97.6
BA A- 101.86
CB A 102.37
DC A 104.29
ED A 104.92
FE A 106.29
GF A- 111.84
HG A+ 121.91
IH A- 123.64
--
View this message in context: http://r.789695.n4.nabble.com/Need-data-labels-to-jitter-with-datapoints-in-boxplot-tp4712380.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list