SOLUTION 2
Here is another solution that looks pretty simple. Each number is represented by one vertical line. All in one plot statement.
%# create the matrix and get coordinates of 1s. a = logical([ 0 0 1 1 0 1 0 0 1 0 1 1 1 0 0 1 0 1 1 1 0 1 0 0 1 1 1 0]); [rc] = find(flipud(a)); plot([cc]',[r-0.5 r+0.5]','k-') xlim([min(c)-0.5 max(c)+0.5]) set(gca,'xtick',[],'ytick',[]) box on

SOLUTION 1
Alternatively, you can use the TEXT function to place '|' character in certain coordinates.
[rc] = find(flipud(a)); clf text(c,r,repmat('|',numel(r),1),'FontSize',70,'hor','center','vert','middle') xlim([min(c)-0.5 max(c)+0.5]) ylim([min(r)-0.6 max(r)+0.4]) set(gca,'xtick',[],'ytick',[]) box on
The disadvantage is that you have to play with font sizes and y axis constraints to close the lines.

Side note . It is strange that I could not use only '|' without repmat. Because this character can actually split different lines. Using char(124) has the same effect. I wonder if there is another workaround.
source share