- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- 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 represent the mean with vertical line in a histogram created by hist function in R?

The value of mean is an important characteristic of the data to be represented by a histogram, therefore, one might want to plot it with the histogram. If the histogram is created by using hist function then we can create a vertical line on the histogram with the help of abline function by defining mean of the data for vertical argument v.

## Example

set.seed(101) x<-rnorm(10000,2,0.75) hist(x)

## Output

Adding a blue color line at the mean value of x in the histogram −

abline(v=mean(x),col="blue",lwd=2)

## Output

abline(v=mean(x),col="blue",lwd=8)

## Output

- Related Questions & Answers
- How to apply manually created x-axis labels in a histogram created by hist function in R?
- How to add a vertical line with some value on a scatterplot created by ggplot2 in R?
- How to display mean inside boxplot created by using boxplot function in R?
- How to represent the legend in a plot created by using plot function with colored straight lines or stars in R?
- How to add a horizontal line to the plot created by ggplot2 in R?
- How to create a line chart using ggplot2 with a vertical line in R?
- How to display mean in a histogram using ggplot2 in R?
- How to create vertical line in xyplot in R?
- How to create a horizontal line in a histogram in base R?
- How to create regression model line in a scatterplot created by using ggplot2 in R?
- How to create a vertical line with CSS?
- How to create a dotted vertical line using ggplot2 in R?
- How to create a wide vertical line using ggplot2 with different color in R?
- How to change the background color of a plot created by using plot function in R?
- How to remove the border of the legend of a chart created by plot function in R?

Advertisements