How transform asp=1 from plot in R to ggplots. theme(aspect.ratio = 1) is not the answer.
Problem: Given 3 points, A, B and C, where Distance between A - B is 50 and from C to A or B is 25. This information is stored in a matrix m.hipo.
dput(m.hipo)
structure(c(0L, 50L, 25L, 50L, 0L, 25L, 25L, 25L, 0L), .Dim = c(3L,
3L), .Dimnames = list(c("A", "B", "C"), c("A", "B", "C")))
In R when used regular plot, asp is needed to produce the good plot:
fit.hipo <- cmdscale(m.hipo, eig = TRUE, k = 2)
x.hipo <- fit.hipo$points[, 1]
y.hipo <- fit.hipo$points[, 2]
plot(x.hipo,y.hipo,asp=1) ### Makes the good plot because of asp=1
plot(x.hipo,y.hipo) ### Makes not the desired plot
! https://i.stack.imgur.com/VyktH.jpg "good plot"
! https://i.stack.imgur.com/WBnvy.jpg "Not Desired Plot"
When used ggplots the code is:
datahipo<-data.frame(x.hipo,y.hipo)
dput(datahipo)
structure(list(x.hipo = c(25, -25, -1.13686837721616e-15), y.hipo = c(5.84003863998217e-07,
5.84003863998217e-07, 2.65574210060648e-23)), .Names = c("x.hipo",
"y.hipo"), row.names = c("A", "B", "C"), class = "data.frame")
phipo<-ggplot(datahipo, aes(x.hipo,y.hipo)) +
geom_point(color = 'red') +
geom_text_repel(aes(label = row.names(dist.hipo)),size=8) +
theme_classic(base_size = 24) +
theme(axis.text=element_text(size=24),axis.title=element_text(size=24,face="bold")) +
labs(list(title = "MDS for Control Proteins (Sequence)", x = First Dimension", y = "Second Dimension")) +
theme(axis.line.x = element_line(color="black", size = 1), axis.line.y = element_line(color="black", size = 1))
and produces the same as the not desired plot, even when used:
phipo + theme(aspect.ratio = 1) ### makes the not desired plot.