简体   繁体   中英

Modifying X-axis in R's Sciplot package to include both italics and non-italics text

I have been reading for hours and I still can't figure this out. I really like Sciplot, but I am not familiar enough with R's basic graphical functions to understand how to modify the plots from Sciplot. I want to one thing with this plot: change A. sayanus and L. Cyanellus to italics.

Plot:[ http://i.imgur.com/n8S8FCx.png]

My code:

lineplot.CI(
          Species2,  #categorical factor for the x-axis
          AvgMass,
          Lethal,
          data=d,
          ylab="Metamorph mass (g)",
          xlab=NA)

Also, if anyone knows how to move the trace.label to the left along with the legend contents, that would be great too. For example:

lineplot.CI(
     Species2,  #categorical factor for the x-axis
     AvgMass,
     Lethal,
     data=d,
     trace.label = "Treatment",
     x.leg=1,
     ylab="Metamorph mass (g)",
     xlab=NA)

Plot . As you can see, the legend contents move when I put in x.leg=1, but the trace.label doesn't go with it...

Ok, so I figured it out (well the first part at least). You need to turn the x axis labels off with xaxt , then create a new character vector of labels. Then use axis() to paste those labels back onto the graph. I used at=c(1,2,3) because that is where the original labels were located, which I discovered with axis(side=1) .

plot1<-lineplot.CI(
      Species2,  #categorical factor for the x-axis
      AvgMass,
      Lethal,
      data=d,
      ylab="Metamorph mass (g)",
      xlab=NA,
      xaxt="n",
      x.leg=1)
   labels <- c(expression("Control", italic("A. sayanus"), italic("L. cyanellus")))
   axis(side=1,at=c(1,2,3),labels=labels)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM