r - Scatterplot: color and italicize axis labels -


in r scatterplot want give y-axis labels colours , make part bold, other parts italic. start simple plotting script, done, except making font bold, italic , giving colour:

png("test.png", height=800, width=600, pointsize=15) par(mar=c(5,12,.25,1)) texta=seq(0,100,25) textb=c("start","intermediate1","intermediate2","intermediate3","stop") plot(c(0,runif(8),1),c(0,runif(8),1),axes=f,ylab=na) axis(1) axis(2, at=seq(0,1,.25), labels=paste(texta,"-",textb,sep=""),las=2,cex.axis=1.5) dev.off() 

question: how can make texta bold , coloured (red) , @ same time make textb italic, not bold, standard colour (black).

thanks much.

i use axis both texta , textb, play around line until have acceptable spacing.

edit: don't know how have different colours , fonts within label. workaround, can put both texts closely using text variable x-position. if resize window, might have adjust offsets.

par(mar=c(5,13,.25,1)) texta=seq(0,100,25) textb=c("start","intermediate1","intermediate2","intermediate3","stop") plot(c(0,runif(8),1),c(0,runif(8),1),axes=f,ylab=na) axis(1)  # add texta , textb axis(2, at=seq(0,1,.25), labels=textb, font=3, col.axis=1,las=2,cex.axis=1.5, line=1) text(x=c(-0.3,-0.55,-0.55,-0.55,-0.3), y=seq(0,1,.25), texta, xpd=na, col=2, font=2, cex=1.5)  # check offset need texta: # abline(v=seq(-1,0,.1), xpd=na, col=2) # text(,x=seq(-1,0,.1),y=rep(0,11),labels=seq(-1,0,.1),xpd=na) 

updated result


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -