geom_linerange

geom_linerange(mapping=NULL, data=NULL, stat="identity", position="identity", ...)

An interval represented by a vertical line

This page describes geom_linerange, see layer and qplot for how to create a complete plot from individual components.

What do you think of the documentation? Please let me know by filling out this short online survey.

Aesthetics

The following aesthetics can be used with geom_linerange. Aesthetics are mapped to variables in the data with the aes function: geom_linerange(aes(x = var)). Note that you do not need quotes around the variable name.

Scales control how the variable is mapped to the aesthetic and are listed after each aesthetic.

Aesthetic Default Related scales
xrequiredcontinuous, date, datetime, discrete
yminrequired
ymaxrequired
colourblackbrewer, gradient, gradient2, gradientn, grey, hue, identity, manual
size0.5identity, manual, size
linetype1identity, linetype, manual
alpha1

Layers are divided into groups by the group aesthetic. By default this is set to the interaction of all categorical variables present in the plot.

Parameters

Parameters control the appearance of the geom. In addition to the parameters listed below (if any), any aesthetic can be used as a parameter, in which case it will override any aesthetic mapping.

Returns

This function returns a layer object.

See also

Examples

> # Generate data: means and standard errors of means for prices 
> # for each type of cut 
> dmod <- lm(price ~ cut, data=diamonds) 
> cuts <- data.frame(cut=unique(diamonds$cut), predict(dmod, data.frame(cut = 
+ unique(diamonds$cut)), se=T)[c("fit","se.fit")]) 
>  
> qplot(cut, fit, data=cuts) 
  
> # With a bar chart, we are comparing lengths, so the y-axis is 
> # automatically extended to include 0 
> qplot(cut, fit, data=cuts, geom="bar") 
  
>  
> # Display estimates and standard errors in various ways 
> se <- ggplot(cuts, aes(cut, fit, 
+   ymin = fit - se.fit, ymax=fit + se.fit, colour = cut)) 
> se + geom_linerange() 
  
> se + geom_pointrange() 
  
> se + geom_errorbar(width = 0.5) 
  
> se + geom_crossbar(width = 0.5) 
  
>  
> # Use coord_flip to flip the x and y axes 
> se + geom_linerange() + coord_flip() 
  

What do you think of the documentation? Please let me know by filling out this short online survey.