geom_linerange


Geometry representing a vertical interval defined by x, ymin and ymax. Each case draws a single graphical object.

Aesthetics

x, ymin, ymax required position aesthetics
alpha, colour, fill, line type, group, size classic aesthetics properties

Similar Geometries

geom_crossbar, geom_pointrange

Description and Details

Using the described geometry, you can insert a simple geometric object into your data visualization – a line defined by a position aesthetic parameters x, ymin and ymax. You can find this geometry in the ribbon toolbar tab Layers, under the 2D button.

Using this geometry, you can display a range of y values at a defined value on the x-axis. We often use this geometry for visualizing errors. For the following examples, we will use a simple dataset consisting of five variables and four records.

We map the trt variable to the x axis. The ymin and ymax ranges are mapped to the variables upper and lower. Finally, we map the color aesthetic to the group variable. The result is shown in the following plot.

Described geometry is often used when on the x-axis are mapped categorical values. If you want to transform the numerical trt variable to categorical, put it as an argument into the factor() function. If you want to see the geometries "next to each other", set the position property to dodge and specify the width parameter to 0.3. The result is shown in the following figure.