This is an R question.
I want to add a vertical line at the position of mean value in histogram.
My code is:
abline(h=0,v=mg,col="red")#mg is the mean value.
But there are two lines come out, except the one I want, also a horizontal line along with X-axis show up.
How can I generate only one line (the vertical line) I want?
Thank you so much for your help!
In the chart, select the data series that you want to add a line to, and then click the Chart Design tab. For example, in a line chart, click one of the lines in the chart, and all the data marker of that data series become selected. Click Add Chart Element, and then click Gridlines.
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.
Omit the h
argument. Each addition to the h
and v
arguments in abline
generates a line.
abline(v=mg,col="red")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With