2016-07-19 5 views
1

Rのプロットからggplotsへの変換asp = 1の変換方法テーマ(aspect.ratio = 1)は答えではありません。cmdscaleを使用してプロットからasp = 1に翻訳する

問題:A-B間の距離が50で、CからAまたはBまでの距離が25である3点A、B、Cが与えられています。この情報は行列m.hipoに格納されます。定期的なプロットを使用Rで

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"))) 

は、ASPは、良好なプロットを作成するために必要とされる:

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 

http://imgur.com/9wENc7I「良いプロット」

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)) 

と使用しても望ましくないプロット、同じを生成します:ここで

phipo + theme(aspect.ratio = 1) ### makes the not desired plot. 
+0

dput(datahipo)を追加できますか?その再現性のために – Nate

+0

はい、初期データ(m.hipo)とdatahipoのためにdputを追加しました。 –

+0

私はちょっと試してみて、私の積み重ねの方法で仕事をしています。 – Nate

答えて

0

は回避されたコードがある場合は使用ggplots http://imgur.com/iGumf4b

を「プロットを希望しません」 :

lim_var <- max(datahipo) 

ggplot(datahipo, aes(x.hipo,y.hipo)) + 
    geom_point(color = 'red') + 
    coord_fixed(xlim = c(-lim_var, lim_var), ylim =c(-lim_var, lim_var)) 

解決策を試したところ、answerはaosmithによってリンクされていましたが、目的の結果が得られませんでした。なぜこれが、多分グラフィックスデバイスの設定ですか、誰にもアイデアはありますか?

関連する問題