I have a matrix in which each element is a pure categorical variable "a","b","c","d",... Each column of the matrix is a chronological entry and now I want to plot the matrix by row and I hope the y-axis is the sequence of characters.
Here is the original matrix:
Here is what I wanted the plot to be:
The red plot is first row of the matrix and the blue plot is the fifth.
I have tried some existing packages but mostly they require me to transfer the categorical variables to numerical variables. So I wonder if anyone could help me with this. Many thanks!
Without your data, I have to generate some toy one, called
mat
, with 5 rows and 10 columns, filled withletters[1:7]
.Basically you need first re-represent you character matrix
mat
with integers.Then you just plot (the whole or some rows of) this matrix using
matplot
. Disable the y-axis first then add it later usingaxis
so that you can customize axis labels.Plot of the selected two rows: