Italics in title of Lattice graph

后端 未结 1 1130
逝去的感伤
逝去的感伤 2021-01-07 11:45

I have read the posts on how to create italicized words in a graph title, but it does not seem to be working for me.

#create a list of species
sp <- c(\"E         


        
1条回答
  •  醉话见心
    2021-01-07 11:53

    There argument you are passing to main needs a couple of changes.

    • To use R's plotmath specials (i.e. things like italic()), it should be an expression object rather than a character string. That means doing something like this:

      main = expression(paste("Length-Freq of", italic("E. coruscans"), "by Gear"))
      

      instead of this:

      main = paste("Length-Freq of", italic("E. coruscans"), "by Gear")
      
    • In addition, you are wanting to italicize i's value rather than its name, but if you just type italic(i), lattice will render i's name as a little italic "i" for each species. Use bquote() or substitute() to substitute in i's value instead, as demonstrated here:

      i <- "E. coruscans"
      xyplot(1:10~1:10,
          main = substitute(expr = expression(paste("Species name: ", italic(i))), 
                            env = list(i=i)))
      

    enter image description here

    0 讨论(0)
提交回复
热议问题