Use superscripts in R axis labels

前端 未结 4 550
南旧
南旧 2020-12-24 00:53

Using base graphics in R, how can I add superscripts to axis labels, as one might want to when plotting latitude and longitude axes on a map.

Consider this example:<

4条回答
  •  無奈伤痛
    2020-12-24 01:41

    It works the same way for axes: parse(text='70^o*N') will raise the o as a superscript (the *N is to make sure the N doesn't get raised too).

    labelsX=parse(text=paste(abs(seq(-100, -50, 10)), "^o ", "*W", sep=""))
    labelsY=parse(text=paste(seq(50,100,10), "^o ", "*N", sep=""))
    plot(-100:-50, 50:100, type="n", xlab="", ylab="", axes=FALSE)
    axis(1, seq(-100, -50, 10), labels=labelsX)
    axis(2, seq(50, 100, 10), labels=labelsY)
    box()
    

提交回复
热议问题