We’ll use two datasets : one in wide format and one in long format to use with mapping. Here how two create the datasets :
# wide format
wide <- data.frame(
index = seq_len(100),
Sine = sin(1:100/10),
Cosine = 0.5 * cos(1:100/10),
Sine2 = sin(1:100/10) * 0.25 + 0.5
)
# long format (to use with mapping)
long <- reshape(
data = wide,
times = c("Sine", "Cosine", "Sine2"),
varying = list(2:4),
idvar = "index",
direction = "long",
v.names = "value"
)
You can change type of line with type
argument, available choices are : line, spline, step, area, area-spline, area-step, area-line-range, and area-spline-range. Some examples :
You can use different types for each lines :
With mapping :
You can use a pattern of dashes and gaps for a line by specifying argument dasharray
. Possible values are :
"x1 y1 x2..."
: first dash will be length x1
, following gap length y1
, …Example :
To use different patterns, use a vector with the same length as the data (use 0
for no dash) :
With mapping :
Lines width can be define with width
argument :
Use a vector with same length as lines to use different widths :
With mapping :
You can use both at the same time :