Plot main title in two lines

前端 未结 3 2065
甜味超标
甜味超标 2020-12-03 06:27

I would like to have the title for the plot in two lines, but this does not work, why? and how can I make it work?

CVal<-1 
SumEpsVal<-2 
plot(1:10, ma         


        
3条回答
  •  广开言路
    2020-12-03 06:49

    The root issue is that plotmath does not support newlines within the expressions to be output.

    Control characters (e.g. \n) are not interpreted in character strings in plotmath, 
      unlike normal plotting.
    

    You really need to create and output each line separately.

    For example :

    Lines <- list(bquote(paste("C=", .(CVal))),
                  bquote(paste(sum(xi), "=", .(SumEpsVal))))
    

    Now output each line The text in the list is converted to expressions do.call

    mtext(do.call(expression, Lines),side=3,line=0:1)
    

    enter image description here

提交回复
热议问题