首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当cex.lab在R中不工作时,如何增加x和y轴标签的字体大小?

当cex.lab在R中不工作时,如何增加x和y轴标签的字体大小?
EN

Stack Overflow用户
提问于 2014-02-03 07:44:04
回答 1查看 1.3K关注 0票数 1

我有以下图表:

我想做的是增加X轴和y轴标签的字体大小.

为此,我对这一行代码使用cex.lab

代码语言:javascript
复制
plot(datax2$tau_bar,datax2$anshit_norm,type="b",lty=4,col=mypalette[1],cex.lab=2.5,cex=1.5,lwd=3,main="",pch=8,font.main=1,xlab="",ylab="",xlim=c(0.01,0.4),ylim=c(0,1))

但不知何故字体大小一点也没变?那怎么做呢?

这是生成数字的完整代码:

代码语言:javascript
复制
#!/usr/bin/env Rscript

library(RColorBrewer);
library(gregmisc);

dat<-read.table("http://dpaste.com/1583393/plain/", header=F);
some_thres <- 38; 
final_plot <- paste("Output.pdf",sep="");


# Renaming Variables
dat<-rename.vars(dat,c("V1","V2","V3","V4","V5","V6","V7","V8","V9","V10","V11"),c("cov","ed","err","tau_bar","true_c","true_t","true","false","ans_c","ans_t","ans_hit"));

cv       <- c(35,50,100,200,300);
edis     <- c(4,6);
errorp   <- c(0,1,2,4);


# For line color
mypalette       <- brewer.pal(10,"RdGy") 
col_plot        <- c(mypalette[2],mypalette[10]); 

ltyp <- c(3,4,5,6,7,8)
pcht <- c(0,1,2);

pdf(final_plot,width=30,height=6)

#--------------------------------------------------
# Plotting 
#-------------------------------------------------- 
op <- par(mfrow=c(1,5),   xaxs="i", yaxs="i")

for (i in 1:length(cv)) {
        for (k in 1:length(edis)){

            datax <- subset(dat,cov==cv[i] & err==errorp[1] & ed==edis[k]  & tau_bar <= 0.4 ,select = c(ed,true,false,tau_bar,ans_hit))
            nofrow <- nrow(datax)

          if (nofrow > 0 ) {
             title <- paste(cv[i],"lim",sep="");

              if(cv[i] == 50 & (edis[k]==0 || edis[k]==4)) next;



              false_max <- max(datax$false);
              true_max <- max(datax$true);
              false_min <- min(datax$false);
              true_min <- min(datax$true);

              max_y <- max(false_max,true_max);

             anshit_norm <- datax$ans_hit/some_thres

             fptp_ratio <- (datax$false)/(datax$true + datax$false);
             precision <- 1 - fptp_ratio;

             datax2 <- cbind(datax,anshit_norm,fptp_ratio,precision);

              plot(datax2$tau_bar,datax2$anshit_norm,type="b",lty=4,col=mypalette[1],cex.lab=2.5,cex=1.5,lwd=3,main="",pch=8,font.main=1,xlab="",ylab="",xlim=c(0.01,0.4),ylim=c(0,1))
              mtext(title,side=3,line=2.0,cex=2);
              mtext(expression(paste(some," threshold")),side=1,line=4,cex=1.5)

          }


            for (j in 1:length(errorp)){
                datax_sub <- subset(dat,cov==cv[i] & err==errorp[j] & ed==edis[k]  & tau_bar <= 0.4 ,select = c(ed,true,false,tau_bar,ans_hit))
                nofrow_sub <- nrow(datax_sub)
                if (nofrow_sub > 0 ) {
                    if(cv[i] == 50 & (edis[k]==0 || edis[k]==4)) next;


                    false_max_sub <- max(datax_sub$false);
                    true_max_sub <- max(datax_sub$true);
                    false_min_sub <- min(datax_sub$false);
                    true_min_sub <- min(datax_sub$true);

                    max_y_sub <- max(false_max_sub,true_max_sub);

                    anshit_norm_sub <- datax_sub$ans_hit/some_thres

                    fptp_ratio_sub <- (datax_sub$false)/(datax_sub$true + datax_sub$false);
                    precision_sub <- 1 - fptp_ratio_sub;


                    datax2_sub <- cbind(datax_sub,anshit_norm_sub,fptp_ratio_sub,precision_sub);
                    lines(datax2_sub$tau_bar,datax2_sub$anshit_norm,col=mypalette[j],type="b",cex=1.5,lty=4,pch=8,lwd=3);
                    lines(datax2_sub$tau_bar,datax2_sub$precision,col=mypalette[j],type="b",cex=1.5,lty=1,pch=1,lwd=3);

                  }
            }

    }
}



dev.off();
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-03 08:46:19

您必须使用cex.axis而不是cex.labcex.lab增加标签的字体大小,cex.axis增加轴的刻度标签的大小。

尝试:

代码语言:javascript
复制
plot(1:10, cex.axis=2.5)

要获得关于所有cex.*的完整概述,请查看?par

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21522055

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档