pch en R

Sheeraz Gul 15 febrero 2024
pch en R

Este tutorial demuestra el uso de pch en R.

pch en R

El pch abreviado como trazar carácter es el argumento estándar utilizado para establecer el carácter, que se trazará en diferentes funciones R. El pch también se puede definir como el símbolo explicativo añadido a una trama; este texto explicativo incluye leyendas, etiquetas de ejes o títulos.

Los pch son los símbolos que desea agregar a una trama que explica una determinada cosa. Aquí está la lista de símbolos pch con sus valores.

pch = 0 square
pch = 1 circle
pch = 2 point up triangle
pch = 3 plus
pch = 4 cross
pch = 5 diamond
pch = 6 point-down triangle
pch = 7 square cross
pch = 8 star
pch = 9 diamond plus
pch = 10 circle plus
pch = 11 up and down triangles
pch = 12 square plus
pch = 13 circle cross
pch = 14 square and down triangle
pch = 15 filled square
pch = 16 filled circle
pch = 17 point-up filled triangle
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

El pch se pasa como argumento a la leyenda; el método pch incluirá el valor de la lista anterior. Probemos un ejemplo para el pch.

#data
set.seed(1234)
delftstack <- data.frame(x=runif(10),y=runif(10),
                 color=rep(c("lightblue","red"),5),
                 background=rep(c("red", "lightblue"),5),
                 shape=rep(c(21,24),5),stringsAsFactors = FALSE)

#plot
plot(delftstack$x,delftstack$y,col=delftstack$color,bg=delftstack$background,pch=delftstack$shape,cex=2)
points(x=0.5,y=0.5,pch=8,col="red",cex=2)

#add a legend, pt.bg is needed to fill in the background of the shape
legend(0.01,0.5,
       legend = c(expression("PCH"["Example1"]),
                  expression("PCH"["Example2"]),
                  expression("PCH"["Example"])),
       pch = c(21,24,8),
       col = c("lightblue","red","red"),
       pt.bg = c("red","lightblue"),
       cex=2)

El código anterior traza los datos del marco de datos y luego, en la leyenda, intenta aplicar algunas características, que también incluyen pch. Ver la salida:

PCH en R

Sheeraz Gul avatar Sheeraz Gul avatar

Sheeraz is a Doctorate fellow in Computer Science at Northwestern Polytechnical University, Xian, China. He has 7 years of Software Development experience in AI, Web, Database, and Desktop technologies. He writes tutorials in Java, PHP, Python, GoLang, R, etc., to help beginners learn the field of Computer Science.

LinkedIn Facebook