Reputation: 415
I'd like to add lines to an opened figure in MATLAB e.g. splitting the figure into 15 rows, without plotting it on an axes (I want whatever grid I input to be part of a non interactive background). How is this done?
Upvotes: 2
Views: 4736
Reputation: 42225
Here's how you can manipulate the grid lines so as to give the appearance of dividing the image into 15x15 blocks, without having to plot each on a separate axes.
img=imread('peppers.png');
imagesc(img)
[nX,nY,~]=size(img);
nSeg=15;
set(gca,'xtick',linspace(0,nY,15+1),'xticklabel',[],...
'xgrid','on','xcolor','w',...
'ytick',linspace(0,nX,15+1),'ytickLabel',[],...
'ygrid','on','ycolor','w',...
'gridLineStyle','-','linewidth',1)
To divide a blank figure,
nSeg=15;
set(gca,'xtick',linspace(0,1,15+1),'xticklabel',[],...
'xgrid','on','xcolor','k',...
'ytick',linspace(0,1,15+1),'ytickLabel',[],...
'ygrid','on','ycolor','k',...
'gridLineStyle','-','linewidth',1)
Upvotes: 2