| Classplot {DataVisualizations} | R Documentation |
Allows to plot one time series or feauture with a classification as a labeled scatter plot with a line. The colors are the labels defined by the classification. Usefull to see if temporal clustering has time dependent variations and for Hidden Markov Models (see Mthrun/RHmm on GitHub).
Classplot(X, Y, Cls,Names=NULL, na.rm=FALSE, xlab = "X", ylab = "Y", main = "Class Plot", Colors,Size=8, LineColor = NULL, LineWidth = 1, LineType = NULL, Showgrid = TRUE, Plotter, SaveIt = FALSE)
X |
[1:n] numeric vector or time |
Y |
[1:n] numeric vector of feature |
Cls |
[1:n] numeric vector of k classes, if not set per default every point is in first class |
Names |
[1:n] character vector of k classes, if not set perdefault Cls is used, if set, names the legend and the points |
na.rm |
Function may not work with non finite values. If these cases should be automatically removed, set parameter TRUE |
xlab |
Optional, string for xlabel |
ylab |
Optional, string for ylabel |
main |
Optional, string for title of plot |
Colors |
Optional, string defining the k colors, one per class |
Size |
Optional, size of points |
LineColor |
Optional, name of color, in plotly then all points are connected by a curve, in ggplot2 all points of one class ae connected by a curve of the color the class |
LineWidth |
Optional, number defining the width of the curve (plotly only) |
LineType |
Optional, string defining the type of the curve in plotly only, " for ggplot2: just set =1 here and then the curve is plotted |
Showgrid |
Optional, boolean (plotly only) |
Plotter |
Optional, either " |
SaveIt |
Optional, boolean, if true saves plot as html (plotly) or png (ggplot2) |
Default is "plotly" if Names are NULL. However, ggplot2 is preferable in case that Names parameter is used because overlapping text labels are avoided. In that case the default is "ggplot". Note that ggplot2 options are currently slightly restricted.
plotly object or ggplot2 objected depending on Plotter
Michael Thrun
data(Lsun3D) Classplot(Lsun3D$Data[,1],Lsun3D$Data[,2],Lsun3D$Cls) #plotly with line data(Lsun3D) Classplot(Lsun3D$Data[,1],Lsun3D$Data[,2],Lsun3D$Cls, LineType="-",LineColor = "green") #ggplot2 with line and labels data(Lsun3D) Classplot(Lsun3D$Data[,1],Lsun3D$Data[,2],Lsun3D$Cls, Names = rownames(Lsun3D$Data),Size =2,LineType = 1)