|
Add a Reference Line to a Bar Plot
Horizontal reference lines can be added to a Bar Plot using the abline function. Vertical reference lines cannot be added to bar plots. barplot(ElementContainingData ) abline( h = Axis_Intercept_Value) Example: > barplot(pressure$pressure) > abline(h=200) Customize Reference Lines
The default reference line is a simple black line. However, the line color, line type, and line thickness can be customized. Line Color
The line color can be customized using the col argument. barplot( ElementContainingData ) abline( h = Axis_Intercept_Value, col = "Color") Example: > barplot(pressure$pressure) > abline(h=200, col = "Red") Line Type
The line type can be customized using the lty argument. barplot( ElementContainingData ) abline( h = Axis_Intercept_Value, lty = Line_Type_#) The numbers corresponding to each line type are shown below. Example:
> barplot(pressure$pressure) > abline(h=200, col = "Red", lty = 5) Line Width
The line width can be customized using the lwd argument. barplot( ElementContainingData ) abline( h = Axis_Intercept_Value, lwd = Line_Width_#) Example: > barplot(pressure$pressure) > abline(h=200, col = "Red", lty = 5, lwd = 3) Draw Line behind Bars
The reference line is drawn over the bars by default. It is possible to draw then line behind the bars by re-plotting the bars over the line using the add argument. barplot( ElementContainingData ) abline( h = Axis_Intercept_Value, lwd = Line_Width_#) barplot( ElementContainingData , add = TRUE) Example: > barplot(pressure$pressure) > abline(h=200, col = "Red", lty = 5, lwd = 3) > barplot(pressure$pressure, add = TRUE) |