Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a single line in histogram

Tags:

r

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!

like image 284
zhang525986 Avatar asked Jun 19 '13 19:06

zhang525986


People also ask

How do I add a line to a histogram in Excel?

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.

How do you add a vertical line to a 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.


1 Answers

Omit the h argument. Each addition to the h and v arguments in abline generates a line.

abline(v=mg,col="red")
like image 129
Blue Magister Avatar answered Sep 27 '22 20:09

Blue Magister