rmf rmf - 1 year ago 146
R Question

R legend pch mix of character and numeric

Is it possible to use a mix of character and number as plotting symbols in R legend?

legend(7,4.5,pch=c("+",16),legend=c("A","B")) #This is the problem

Answer Source

My first thought is to plot the legend twice, once to print the character symbols and once to print the numeric ones:

legend(7,4.5,pch=c(NA,16),legend=c("A","B")) # NA means don't plot pt. character 

NOTE: Oddly, this works in R's native graphical device (on Windows) and in pdf(), but not in bmp() or png() devices ...

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download