- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create a plot in R with gridlines using plot function?
Any plot created by using plot function does not display the plot with gridlines. On the other hand, if we create a plot using ggplot2 package then the plot has gridlines. Therefore, if we want to have gridlines on our plot then either we should create the plot using ggplot2 package or we can use the command grid() to add the gridlines on the plot created by plot function.
Example
Creating a histogram using plot function −
> hist(rnorm(100))
Output
Adding the grid lines to the above plot −
> grid()
Output
- Related Articles
- How to create gridlines that matches with Y-axis values in the plot created by using plot function in R?
- How to create a plot in R with a different plot window size using plot function?
- How to create a line chart in R using plot function with larger width?
- How to create a horizontal bar plot using barplot function in R?
- How to plot a function with ggplot2 in R?
- How to create a bar plot with ggplot2 using stat_summary in R?
- How to create stacked plot with density using ggplot2 in R?
- How to create the stacked bar plot using ggplot2 in R with labels on the plot?
- How to create a dot plot using ggplot2 in R?
- How to create a plot using rgb colors in R?
- How to plot a function in R?
- How to create a plot title with unicode characters using ggplot2 in R?
- How to create a plot with cross sign in R?
- How to write the plot title in multiple lines using plot function in R?
- Add minor gridlines to Matplotlib plot using Seaborn

Advertisements