Creating a graphical style "timeline" in MATLAB

At the end of some data processing in MATLAB, I want to create a graph that shows the colored lines of the timeline for a series of data. I have several processes, each of which goes through similar steps, and also starts and stops and differs at different times. Ideally, it would look something like this (forgive ASCII art):

  |  ### *** $$$$$$$$$$ Process 1
    |  ### *** $$$$$$$ Process 2
    |  ### $$$$$ Process 3
    |  ******* $$$$$$ Process 4
    + ------------------------------------------
                     Time

Where # * and $ stand for solid adjacent blocks of different colors (one color at each step goes through processes, note that some are optional).

Labels may be in another place, but next to each line is good.

I hacked the solution using rectangle and text , but it looks like it could be an existing type of chart inside MATLAB that I haven't found yet. Do you know about this?

+6
matlab graphics
source share
1 answer

Use barh . Set the first column as the start time of the process

 data_with_init_time = [ 1, 10, 5, 3 ; 3, 10, 3, 9 ; 7, 10, 4, 8 ; 12,10, 2, 2 ]; h = barh(data_with_init_time, 'stack'); set(h(1), 'facecolor', 'none', 'EdgeColor', 'none'); % disable the color of the first column (init time) set(gca, 'YTickLabel', {'proc 1', 'proc 2', 'proc 3', 'proc 4'} ); % change the y axis tick to your name of the process axis ij; % Put the first row at top 
+9
source share

All Articles