geom_crossbar


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

Aesthetics

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

Other Properties

width crossbar width
fatten a multiplicative factor used to increase the size of the middle bar in geom_crossbar and the middle point in geom_pointrange

Similar Geometries

geom_linerange, geom_pointrange

Description and Details

Using the described geometry, you can insert a geometric object (crossbar) into your data visualization that is defined by a position aesthetics properties x, y, 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 to the x axis the trt variable. On the y, ymin and ymax positional properties we map variables resp, 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 we have categorical variable mapped on the x-axis. If we want to transform numerical variable trt to categorical, we put it as an argument into the factor() function. For displaying the geometries "next to each other", we set the position property to dodge and the width parameter to 0.2. Finally, we can adjust the thickness of the middle bar using the fatten property (we set it to 6). The result is shown in the following figure.