Site icon R-bloggers

R Plot pch Symbols: Different point shapes in R

[This article was first published on Methods – finnstats, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

R plot pch symbols, In this tutorial we are going to describe different pch values in R.  The plotting argument used to specify point shapes is pch.

Let’s install the ggpubr package from cran, and then plot different shapes in R.

#install.packages("ggpubr")
ggpubr::show_point_shapes()

R Plot pch Symbols

The 25 different points symbols are commonly used in R for making beautiful graphs.

tidyverse in r – Complete Tutorial » Unknown Techniques »

Let create a default plot pch = 1 (empty circle)

Deep Neural Network in R » Keras & Tensor Flow

plot(x = mtcars$mpg, y = mtcars$disp, frame = FALSE,
     xlab = "MPG", ylab = "DISP")

As mentioned above, we can change different pch values.

Principal component analysis (PCA) in R »

Change plot symbol to pch = 8 (star)

plot(x = mtcars$mpg, y = mtcars$disp, frame = FALSE,
     xlab = "MPG", ylab = "DISP",
     pch = 8)

If you want to change the color and the size of points, use the following arguments

For making attractive plots you can make use of bg and lwd arguments also.

If you want to know more about lwd check it here

Line types in R: Ultimate Guide For R Baseplot and ggplot »

Change color and background

plot(x = mtcars$mpg, y = mtcars$disp, frame = FALSE,
     xlab = "MPG", ylab = "DISP",
     pch = 8, col =  "#FF0000")

Use pch = 21 and change border line width (lwd), and background color (bg)

plot(x = mtcars$mpg, y = mtcars$disp, frame = FALSE,
     xlab = "MPG", ylab = "DISP",
     pch = 21, bg = "red", col = "black",
     lwd = 0.9, cex = 1.5)

QQ-plots in R: Quantile-Quantile Plots-Quick Start Guide »

Enjoyed this article? Don’t forget to show your love, Please Subscribe the Newsletter and COMMENT below!

The post R Plot pch Symbols: Different point shapes in R appeared first on finnstats.

To leave a comment for the author, please follow the link and comment on their blog: Methods – finnstats.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.