1

に問題がありgeom_textます。異なる色を付けた 2 つのポイント セットがあり、線形モデルを使用して両方のセットに線を当てはめました。

線の方程式、ピアソンの相関、スピアマンの相関を追加しようとすると、凡例に文字が表示され、テキストがピクセル化されます。どうすればこれを修正できますか?

個別にプロットするとこの問題は発生しませんが、まとめてプロットします。

library(ggplot2)
library(reshape2)

lm_eqn = function(df){
    m = lm(area ~ Mass, df);
    eq <- substitute(italic(y) == a + b %.% italic(x)*","~~italic(r)^2~"="~r2, 
         list(a = format(coef(m)[1], digits = 2), 
              b = format(coef(m)[2], digits = 2), 
             r2 = format(summary(m)$r.squared, digits = 3)))
    as.character(as.expression(eq));                 
}

lm_eqn_PA = function(df){
    m = lm(area ~ Mass, df);
    eq <- substitute(italic(y) == a + b %.% italic(x)*","~~italic(r)^2~"="~r2, 
         list(a = format(coef(m)[1], digits = 2), 
              b = format(coef(m)[2], digits = 2), 
             r2 = format(summary(m)$r.squared, digits = 3)))
    as.character(as.expression(eq));                 
}


dat <- read.table("../../mass_vs_area/mass_vs_area.txt",header=TRUE)
area <- read.table("../results/all_values.txt", header=TRUE)

all_dat <- merge(area,dat,by="file")

all_dat1 <- data.frame(file=all_dat$file,Mass=all_dat$Mass,area=all_dat$area,Cluster=c("Experimental"))
all_dat2 <- data.frame(file=all_dat$file,Mass=all_dat$Mass,area=all_dat$PA,Cluster=c("PA"))

plot_dat = rbind(all_dat1,all_dat2)

data.label.equation1 <- data.frame(x = 250,y = 20000,label = paste("Exp_eq.: ",lm_eqn(all_dat1)))
data.label.pearson1 <- data.frame(x = 250, y = 21000,label = paste("Exp_Peasron: ",format(cor(all_dat1$Mass,all_dat1$area),digits=3)))
data.label.spearman1 <- data.frame(x = 250, y = 22000, label = paste("Exp_Spearman: ",format(cor(all_dat1$Mass,all_dat1$area,method="spearman"),digits=3)))

data.label.equation2 <- data.frame(x = 250,y = 19000,label = paste("PA_eq.: ",lm_eqn_PA(all_dat2)))
data.label.pearson2 <- data.frame(x = 250, y = 18000,label = paste("PA_Peasron: ",format(cor(all_dat2$Mass,all_dat2$area),digits=3)))
data.label.spearman2 <- data.frame(x = 250, y = 17000, label = paste("PA_Spearman: ",format(cor(all_dat2$Mass,all_dat2$area,method="spearman"),digits=3)))


plotter <- (qplot(data=plot_dat, x=Mass, y=area, colour=factor(plot_dat$Cluster)) + geom_point(shape=1) + geom_smooth(method="lm") + scale_colour_discrete(name="Cross-Section Type"))

plotter <-  plotter + labs(x = "Mass kDa" ,y = expression(paste('CCS (',Å^2,')')))
plotter <- plotter + geom_text(data = data.label.equation1, aes(x = x , y = y, label = label) ,parse=TRUE)
plotter <- plotter + geom_text(data = data.label.pearson1, aes(x = x , y = y , label = label ),parse=TRUE)
plotter <- plotter + geom_text(data = data.label.spearman1, aes(x = x , y = y , label = label ),parse=TRUE)

plotter <- plotter + geom_text(data = data.label.equation2, aes(x = x , y = y , label = label ),parse=TRUE)
plotter <- plotter + geom_text(data = data.label.pearson2, aes(x = x , y = y , label = label ),parse=TRUE)
plotter <- plotter + geom_text(data = data.label.spearman2, aes(x = x , y = y , label = label ),parse=TRUE)

print(plotter)

ここに画像の説明を入力

以下のデータフレームを編集します。

all_dat1 table:
          file Mass  area      Cluster
1         1bsy   18  1660 Experimental
2         1fi9   12  1240 Experimental
3  1gr5_edited  801 20900 Experimental
4    1gyk_edit  125  7030 Experimental
5         1hwz  336 12800 Experimental
6  1jyc_edited  103  5550 Experimental
7   1pkn_model  237 10300 Experimental
8   1ttr_model   56  3410 Experimental
9   2a3y_model  250 10400 Experimental
10        2hcy  143  6940 Experimental
11  3blg_model   37  2850 Experimental
12  3fdc_model   64  3640 Experimental
13       4f5sA   69  4090 Experimental

all_dat2 table:

        file Mass  area Cluster
        1bsy   18  1428      PA
        1fi9   12  1119      PA
 1gr5_edited  801 21518      PA
   1gyk_edit  125  5592      PA
        1hwz  336 10759      PA
 1jyc_edited  103  4649      PA
  1pkn_model  237  8689      PA
  1ttr_model   56  2793      PA
  2a3y_model  250  8514      PA
        2hcy  143  7255      PA
  3blg_model   37  2399      PA
  3fdc_model   64  2833      PA
       4f5sA   69  3871      PA
4

1 に答える 1

1

凡例からシンボルを削除するには、すべてgeom_textにオプションを追加します

   show_guide =FALSE
于 2012-12-10T14:43:43.703 に答える