MATLAB: Lines disappearing on plot

subplot

Hey there,
I am having a weird problem with a specific type of plot I like to make. There are three pictures attached. What I am doing is making a kind of heat map, then adding 4 black lines to denote the borders of something (top image in attachment). Then what I do is concatenate several of these heat maps side-by-side to represent my data changing in time in a subplot. I initially plot using:
h1 = subplot(3,1,i); imagesc(B); colormap(gray);
Where the variable 'B' is the heat map I am plotting (as in image #1 in attachment). When I do this, however, one of the black lines I original put on B is gone (image #2). Another one of the black lines disappears when I use 'axis image' and then make the plot prettier with the code below:
axis image;
x_lims = get(gca,'xlim');
x_lng = x_lims(2)-x_lims(1);
new_ticks = round(x_lng/numEpochs*(1:numEpochs-1));
set(gca,'xtick',new_ticks)
x_tic = get(gca,'XTick');
y_lims = get(gca,'YLim');
ylabel(tag2,'FontSize',13,'FontWeight','Bold')
set(gca, 'ytick', [], 'yticklabel', [], 'CLim', [0, 255]);
set(gca,'xticklabel',XTL+stimDur,'tickdir','out','FontWeight','Bold','FontSize',12)
set(gca,'ydir','reverse'); set(gca,'LineWidth',2);
set(gca,'xtick',x_tic)
The bottom image in the attachment shows what I end up with, which is my intended subplot, except that two sides of my rectangle are missing…
Does anyone see what I can do differently to prevent this from happening?

Best Answer

Did you draw the line in the image itself? Or display it in the graphical overlay with the line() function? If it's in the image and only one pixel wide, then if the image gets shrunk down for display it's possible it won't appear due to which pixels get taken when it subsamples the image.