R pch Symbol Library Plot

R_pch_plotApparently, my brain cannot retain the R pch code index on its own. And I got tired of Google-Imaging (is that a legit verb?) “R pch” every time I needed to sort out a symbol. So I made a quick plot (mostly for my own use) of all the pch symbols (to add to the hundreds of others on the internet). So here it is.

The pch code is (somewhat obviously) the sum of the Y and X coordinates on the plot.
e.g. the @ symbol is pch=60+4 or 64.

Incidentally, I also came across  this post on how to use unicode (hexidecimal) symbols on your R plots. Maybe there’s a Death Star symbol in there that I can sneak into a publication some time.

For the three of you who just must know how this is coded:

# Make the data
pch.dat <- data.frame(expand.grid(X=1:10, Y=seq(0,250,10)), PCH=1:260)
# Set up the plot window
graphics.off()
x11(w=7, h=11)
par(mar=c(5,5,3,5))
# Make the plot
plot(Y~X, data=pch.dat, type="n", axes=F)#, main="R pch = X + Y")
abline(h=seq(0,250,10), col="gray90", lwd=20)
abline(v=1:10, col="gray90", lwd=20)
points(Y~X, data=pch.dat, pch=pch.dat$PCH, cex=1.2, col="black", bg="red")
axis(1, at=1:10, las=1)
axis(2, at=seq(0,250,10), las=1)
axis(3, at=1:10, las=1)
axis(4, at=seq(0,250,10), las=1)
box()
savePlot("R_pch_plot.png", type="png")
Advertisements
This entry was posted in R and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s