matlab - imagesc with multiple axis and ticklines -
i have [12 x 6]
matrix a
represent imagesc
, on impose thick tick-lines:
figure imagesc(a) set(gca,'xtick', linspace(0.5,size(a,2)+0.5,c+1),... 'ytick', linspace(0.5,size(a,1)+0.5,b*al+1),'linewidth',3); set(gca,'xgrid', 'on', 'ygrid', 'on', 'gridlinestyle', '-', 'xcolor', 'k', 'ycolor', 'k'); set(gca, 'xticklabelmode', 'manual', 'xticklabel', [],'yticklabel', []); colorbar
i want impose thinner tick-lines split in 2 each box delimited thicker lines:
ax1 = gca; ax1_pos = get(ax1,'position'); % position of first axes ax2 = axes('position',ax1_pos,... 'xaxislocation','top',... 'yaxislocation','right',... 'color','none'); set(gca,'xtick', linspace(0.5,size(a,2)+0.5,2*c+1),'linewidth',1);
the result not satisfying. how fix it? thought 'color','none'
have done trick...
instead of trying modify tick lengths , adding second axes, plot lines on top of image. should achieve want:
% sample data: = rand(12, 6); % plot image: imagesc(a); set(gca, 'visible', 'off'); hold on; colorbar; % plot horizontal lines: ylines = repmat((0:size(a, 1))+0.5, 2, 1); xlines = repmat([0.5; size(a, 2)+0.5], 1, size(ylines, 2)); line(xlines, ylines, 'linewidth', 3, 'color', 'k'); % plot thick vertical lines: xlines = repmat((0:2:size(a, 2))+0.5, 2, 1); ylines = repmat([0.5; size(a, 1)+0.5], 1, size(xlines, 2)); line(xlines, ylines, 'linewidth', 3, 'color', 'k'); % plot thin vertical lines: xlines = repmat((1:2:size(a, 2))+0.5, 2, 1); ylines = repmat([0.5; size(a, 1)+0.5], 1, size(xlines, 2)); line(xlines, ylines, 'linewidth', 1, 'color', 'k');
and here's plot:
Comments
Post a Comment