Subplots in an "axes" object

114 views (last 30 days)
K BV
K BV on 27 Jun 2012
Hi,
I would like to sublot four images (X(:,:,1) -> X(:,:,4)) in an "axes" object (axes1) but every time I have one image displayed and not the totality of the images.
Here is the part of my code which nomally should do that :
if(1<=nb_coupes)
axes(handles.axes1)
subplot(121)
imagesc(X(:,:,1)), colormap gray, axis('image'),axis('off'),colormap gray,zoom(2);
setappdata (Feature_Tracking,'images',X);
end
if(2<=nb_coupes)
hold on
subplot(122)
imagesc(X(:,:,2)), colormap gray, axis('image'),axis('off'),colormap gray,zoom(2);
setappdata (Feature_Tracking,'images',X);
end
if(3<=nb_coupes)
hold on
subplot(211)
imagesc(X(:,:,3)), colormap gray, axis('image'),axis('off'),colormap gray,zoom(2);
setappdata (Feature_Tracking,'images',X);
end
set(handles.axes1,'String',FileName)
axes(handles.axes1)
imagesc(X(:,:,1)), colormap gray, axis off, axis image
setappdata (Feature_Tracking,'images',X);
Would you please help me solving the problem ?
Thank you in advance !

Accepted Answer

Walter Roberson
Walter Roberson on 27 Jun 2012
You cannot do this. subplot() creates new axes for the plots, and cannot plot inside an axes.
See also this part of the subplot documentation:
If a subplot specification causes a new axis to overlap a existing axis, the existing axis is deleted - unless the position of the new and existing axis are identical. For example, the statement subplot(1,2,1) deletes all existing axes overlapping the left side of the figure window and creates a new axis on that side—unless there is an axes there with a position that exactly matches the position of the new axes (and 'replace' was not specified), in which case all other overlapping axes will be deleted and the matching axes will become the current axes.
  1 Comment
K BV
K BV on 2 Jul 2012
Thanks for the answer WR.
I could display my images as I wished.

Sign in to comment.

More Answers (0)

Categories

Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!