r - How to format the title in ggplot2 -


i have data name "catch" , observations are:

x  y 0.50 3.66 0.63 3.95 0.77 5.82 0.92 7.38 1.07 8.58 1.24 9.31 1.42 9.52 1.61 9.52 1.81 9.58 2.04 9.54 2.29 9.56 2.56 9.44 2.87 9.07 3.21 8.61 3.61 7.92 4.09 7.04 4.67 5.93 5.43 4.52 6.52 2.90 8.43 0.63 

i used code in r:

library(ggplot2) ccplot <- ggplot(data = catch, aes(x = x, y = y)) +           geom_point(shape = 19, colour = "#0072b2")  ccplot <- ccplot + geom_abline(intercept = 14.58, slope = -1.85, col = "#d55e00")  ccplot2 <- ccplot +             xlab("time") +             ylab(expression(paste("ln[c(l1, l2)]/(", delta, "t)")))  ccplot2 + ggtitle(expression(paste("length-converted catch curve\n(for z=1.85; m(at 23"*degree*"c)=0.69; f=1.16; e=0.63"), hjust = 0)) 

the problem arises when printed plot have large (distant) space between number 23 , degree symbol.

the plot printed above code

how format title space gone? or there other method accomplish proper title in ggplot2?

thank in advance.

you're better off using unicode degree symbol rather trying use plotmath in case.

ccplot2 + ggtitle(expression("length-converted catch curve\n(for z=1.85; m(at 23\u00b0c)=0.69; f=1.16; e=0.63)"), hjust=0) 

you use atop() expression layout

ccplot2 + ggtitle(expression(atop("length-converted catch curve","(for z=1.85; m(at 23"~degree~"c)=0.69; f=1.16; e=0.63)"))) 

what's happening code it's printing first string (with new line), when switch math mode degree, exit string , start right of two-lined string.


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -