geom_spoke
geom_spoke is a polar parameterization of geom_segment
geometry. It is useful when you have variables that are
based on the direction and distance (or speed).
Aesthetics
Similar Geometries
geom_segment,
geom_path,
geom_line
Description and Details
Using the described geometry, you can insert a geometric
object into your data visualization – a layer of line
segments that are defined by two positional aesthetic
properties (x and y) and two variables that describes
the line segment angle and radius. You can find this
geometry in the ribbon toolbar tab Layers, under the
Primitives button.
For the following examples, we use a dataset whose structure
is shown in the following table. The dataset contains
the coordinates x and y that will define the position of
the displayed line segments and angle, speed variables
that will be used for the definition of aesthetic parameters
angle and radius.
If we map the x and y variables to positional aesthetics
and use the point geometry, the resulting graph will look
like the following figure. These points represent the
initial coordinates from which the line segments will be rendered.
To the graph we insert the geom_spoke object and map the
positional aesthetics as in the previous case. On the angle
property we mapped variable (with the same name) from the
dataset. The radius property was set to constant value of
0.5 (for all displayed line segments). After this, the result
will look like in the following chart.
Like the angle aesthetic, it is possible to map the variable
from dataset to the radius property. Subsequently, the length
of the individual line segments will depend on the values of
selected variable. The example is shown in the following figure.
The last example shows the advanced options for setting the
geom_spoke layer. In addition to the radius we mapped the
speed variable to the color aesthetic. Since the geom_spoke
is a line object, we can also define arrow heads using the
arrow property. A description of its functionality and setting
can be found, for example, in the chapter about geom_path
or geom_segment geometry. By setting these properties you can
create data visualization as in the following figure.