Data Science – Commonly Used Plot Parameters in R Programming

0
This article represents some of the commonly used plot parameters across different plot commands, while you are working with different kind of plots in R. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos.
Following are the key points described later in this article:

  • What are some of the common plots (commands) in R?
  • Commonly Used Plot Parameters

 

What are some of the common plots (commands) in R?

Following represents some of the plots (commands) used in R language for different purposes. I shall be writing different blog on different use-cases where one should use one or more of the following plots:

  • plot
  • barplot
  • hist
  • stem
  • mosaicplot
  • pie
  • boxplot

 

Commonly Used Plot Parameters

Following are some of the commonly used parameters:

  • main: “main” parameter is used to give the title for the plot
  • ylim: “ylim” parameter is used to limit the numbers on the Y-axis. It is defined using following format: ylim=c(0,10) which sets the numbers on Y-axis starting from 0 going upto 10. The plots get adjusted accordingly.
  • xlim: “xlim” parameter is used to limit the numbers on the X-axis. It is defined using following format: xlim=c(0,15) which sets the numbers on X-axis starting from 0 going upto 15. The plots get adjusted accordingly.
  • las: Setting las=1 turns the numbers horizontally on the Y-axis.
  • xlab: xlab=”Label X” sets the label of X-axis to “Label X”
  • ylab: ylab=”Label Y” sets the label of Y-axis to “Label Y”
  • col: col is used to set the color of the plotting points or line wherever applicable with different kind of plots. For example, col=2 sets the color as red. col=4 sets the color as blue. One could use additional attributes with col to change the color of title (col.main), labels (col.lab), axis points (col.axis)
  • lwd: lwd is used to set the width of the line in the plots. The value could be 1,2,3,4,5 etc.
  • cex: “cex” argument is used to change the size of the plotting characters. cex with further attributes could be used to change the size of title (cex.main), x and y-axis labels (cex.lab), x and y-axis (cex.axis) points etc.
  • font: font command is used to change the font of title (font.main), labels (font.lab), axis (font.axis) etc.

For pie-charts, only “main” makes sense to be used.

 

Ajitesh Kumar

Ajitesh Kumar

Ajitesh has been recently working in the area of AI and machine learning. Currently, his research area includes Safe & Quality AI. In addition, he is also passionate about various different technologies including programming languages such as Java/JEE, Javascript and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data etc.

He has also authored the book, Building Web Apps with Spring 5 and Angular.
Ajitesh Kumar

Leave A Reply

Time limit is exhausted. Please reload the CAPTCHA.