pch in R (Plot Characters & Symbols)

Plot Characters or pch are built-in shapes/symbols in R. There are 26 built-in shapes in R and can be identified using the index numbers from 0 to 25. These shapes are used while making plots. For example, a scatter plot uses dot shapes to plot the data. But, using pch, we can modify it to any other shape of our choice.

Plot Character Symbols in R

These are the pch shapes in R:

  • pch = 0, square
  • pch = 1, circle
  • pch = 2, triangle point up
  • pch = 3, plus
  • pch = 4, cross
  • pch = 5, diamond
  • pch = 6, triangle point down
  • pch = 7, square cross
  • pch = 8, star
  • pch = 9, diamond plus
  • pch = 10, circle plus
  • pch = 11, triangles up and down
  • pch = 12, square plus
  • pch = 13, circle cross
  • pch = 14, square and triangle down
  • pch = 15, filled square
  • pch = 16, filled circle
  • pch = 17, filled triangle point-up
  • pch = 18, filled diamond
  • pch = 19, solid circle
  • pch = 20, bullet (smaller circle)
  • pch = 21, filled circle blue
  • pch = 22, filled square blue
  • pch = 23, filled diamond blue
  • pch = 24, filled triangle point-up blue
  • pch = 25, filled triangle point down blue
Pch
Pch with names and index numbers.

Example

Point Character or pch is used as an argument while plotting charts. Let’s plot a scatter chart using the default iris dataset.

x<-c(2.2,6,3.3,8.6,9,5,6.5,7.4)
y<-c(11.6,12,3.2,4.9,7.7,13.3,5.5,5.7)
#Plot with default symbols
plot(x,y)
Plot with default symbols
Plotting data with default symbols or shapes.
#Plot with diamond plus symbols
plot(x,y,pch=9)
Plot with diamond plus symbols
Plotting data with diamond plus symbol or shape.

Displaying all Point Character symbols

Run the following code to display all pch shapes or symbols:

pch_symbols<-function(){
old_Par<-par()
par(font=2, mar=c(0.5,0,0,0))
y=rev(c(rep(1,6),rep(2,5), rep(3,5), rep(4,5), rep(5,5)))
x=c(rep(1:5,5),6)
plot(x, y, pch = 0:25, cex=1.5, ylim=c(1,5.5), xlim=c(1,6.5),
axes=FALSE, xlab="", ylab="", bg="blue")
text(x, y, labels=0:25, pos=3)
par(mar=old_Par$mar,font=old_Par$font )
}
pch_symbols()

Leave a Comment