plot.dbcsp: Plot function implemented by dbcsp class

plot.dbcspR Documentation

Plot function implemented by dbcsp class


This function plots an instance before and/or after its DB-CSP projection.


## S3 method for class 'dbcsp'
plot(x, class = 1, index = 1, vectors = 1:(x@q*2), pairs=TRUE,
     before = TRUE, after = TRUE, legend = FALSE, getsignals = FALSE, ...)



object of class dbcsp.


integer, which of both classes to access (1 or 2), by default class=1


an integer, representing which instance of the class to plot, by default index=1.


an integer or vector of integers, representing the vectors to plot after the projection, by default all the vectors used in the projection are plotted vectors=1:(x@q*2).


logical, if TRUE the pairs of the indicated vectors are also shown, by default pairs=TRUE.


logical, if TRUE the original signals are plotted, by default before=TRUE.


logical, if TRUE the signals after projection are plotted, by default after=TRUE.


logical, if true the legend of the transformed signals is shown, by default legend=FALSE. When plotting more than 15 pairs of signals (15*2=30 signals), the legend is not shown. If before=TRUE legends are not displayed.


logical, if TRUE the projected signals for the selected class, instance and vectors are returned, by default getsignals=FALSE.


optional arguments inherited from the matplot method.


It plots an instance before and/or after being projected with the DB-CSP filter. Vectors values must lie between 1 and 2*q, being q the number of dimensions used to perform the DB-CSP algorithm when creating the dbcsp object. The following should be taken into account when plotting:

  • The first q values (1,...,q) are indicated as, and are plotted with solid lines.

  • The last q values (q+1,...,2*q) are indicated as, and are plotted with dashed lines.

If pairs=TRUE, it is recommended that vectors<q for better understanding, since their pairs are plotted as well. In case that vectors>q, it should be noted that the values are displayed from b1 to bq, where b1 and bq represent q+1 vector and 2*q vector, respectively. The paired vectors (a1-b1, a2-b2, ...) are plotted with the same color, but different line type.

For example if q=15 and plot(object, vectors=16, pairs=FALSE), b1 (16-q=1) vector is shown.

The number of rows and columns of the layout (mfrow, mfcol) can not be modified, as the function select them according to before and after parameters.


Displays a plot of the selected instance before and/or after the DB-CSP filter projection. The vectors shown after the projection are differentiated by the q first and q last vectors, since the former maximize the variance of one class and minimize the variance of the other, while the latter do the opposite. If getsignals=TRUE, a matrix with the projected signals shown in the plot is returned.

See Also

dbcsp, print, summary, train, selectQ, predict, boxplot


# Read data from 2 classes
x <-$come
y <-$five
mydbcsp <- new("dbcsp", X1 = x, X2 = y)
plot(mydbcsp,class=2,index=30,vectors=1:5,before=FALSE, legend=TRUE)
pSignals <- plot(mydbcsp,class=2,index=30,vectors=1:5,before=FALSE, legend=TRUE,getsignals=TRUE)

dbcsp documentation built on June 30, 2022, 5:05 p.m.