Stewart Wiseman
Stewart Wiseman

Reputation: 705

Overlay custom axes to a plot created by symbols

Struggling with this one. I have 25 data items that I want plotted with bubbles in 5 columns. The plot can be re-created thus:

 xcord <- c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5)
 ycord <- c(1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5)
 zsize <- c(2,1,2,3,6,8,9,1,4,5,5,6,7,8,8,9,5,5,5,5,1,8,1,1,12) 

Save the parameters before I change them:

 op <- par()
 dev.off()

Change the parameters:

 par (mfrow=c(1,0), mar=c(2,2,2,2), oma=c(2,2,2,2)) 

Plot using symbols:

 symbols(xcord, ycord, zsize, inches=0.3, fg="white", bg="red", xlab="Events", ylab="Diagnoses", tck=0, xaxt="n", yaxt="n")     

 mtext("Rheumatic diagnoses by cerebrovasular events", line=2, font=2, cex=1.2) 

I am happy with the above plot and deliberately used tck=0, xaxt="n", yaxt="n" to clear the axes. I want to manually overlay custom text, controlled with custom co-ordinates (which work with the sysmbols plot), but have not been able to do it. I have tried some of the par arguments and the axes function.

I also tried leaving the axes on:

 symbols(xcord, ycord, zsize, inches=0.3, fg="white", bg="red", xlab="Events", ylab="Diagnoses")        

but do not know how to change the output (1,2,3,4,5) to my own custom axes labels.

Thank you.

Upvotes: 0

Views: 54

Answers (1)

sgibb
sgibb

Reputation: 25736

You are looking for the axis function (see ?axis for details), e.g. to replace the 1:5 with A, B, C, D, E:

axis(side=1, at=1:5, labels=LETTERS[1:5])

Upvotes: 1

Related Questions