I\'d like to reproduce the following base graph with ggplot2.
Following is the
library("ggplot2")
p <- ggplot(data=as.data.frame(G), aes(V1, V2)) +
geom_vline(xintercept=0, colour="green", linetype=2, size=1) +
geom_hline(yintercept=0, colour="green", linetype=2, size=1) +
geom_point() +
geom_text(aes(label=row.names(G)), vjust=1.25, colour="blue") +
geom_path(data=as.data.frame(con.hull), aes(V1, V2)) +
geom_segment(data=as.data.frame(E),
aes(xend=V1, yend=V2), x=0, y=0,
colour="brown", arrow=arrow(length=unit(0.5 ,"cm"))) +
geom_text(data=as.data.frame(E), aes(label=row.names(E)),
vjust=1.35, colour="red") +
labs(list(x=sprintf("PC1 (%.1f%%)", PC.Percent.SS[1]),
y=sprintf("PC2 (%.1f%%)", PC.Percent.SS[2]))) +
xlim(range(c(E[,1], G[,1]))*(1+r)) +
ylim(range(c(E[,2], G[,2]))*(1+r))
tmp <- t(sapply(1:(nrow(con.hull)-1),
function(i) getPerpPoints(con.hull[i:(i+1),])[2, ]))
p <- p + geom_segment(data=as.data.frame(tmp),
aes(xend=V1, yend=V2), x=0, y=0)
print(p)