Skip to content

r scripting charts line

Sebastian Seitner edited this page Jan 4, 2018 · 5 revisions

Line Chart

To use a line chart you have to import the according classes via:

import(at.gmi.djamei.viz.charts.gral.LinePlot)

Parameters

A line chart has the following parameter options

Name Type
data A Matrix of data points, (x,y) value pairs per row
groups A Factor listing the group association of the rows in the data matrix
colors A character vector containing the color values to be used for the different groups
legend A character vector representing the text which should be shown in the legend for the corresponding group
xLabel The label for the X axis
yLabel The label for the Y axis
title The title of the plot

Example

t = seq(0,10,0.1)
y = sin(t)
y1 = cos(t)
data <- cbind(t,y)
data <- rbind(data, cbind(t, y1))
groups <- c(rep("sin",length(t)),rep("cos",length(t)))
colors <- rainbow(2)

line <- LineChart$new(data = data,
    groups = factor(groups, levels = unique(groups)),
    colors = colors,
    legend = c("sine","cosine"),
    xLabel = "X",
    yLabel = "Y",
    title = "Test line plot"
)
phenopipe_add_chart(line)

Be aware that the order of the groups factor matters. Therefore we specify the order of the factor explicitely by providing the levels parameter.

Line Plot Example