I would like to make a x-y-plot that includes the labels inside the plot symbols.
My first attempt is this:
dx <- data.frame(x=c(1,2,3),y=c(3,5,8),z=c(1,10,20))
ggplot(data=dx, aes(x=x,y=y,label=as.factor(z)))+
geom_point(color="black",shape=1,size=6) +
geom_text(hjust = 1, nudge_x = 0.04)
The result is almost ok, but the labels (z
) are not centered in the plot symbol. This probably has to do with the parameters within geom_text()
. What values do I have to choose so that the numbers (z
) are centered in the circles?