f



Matlab7 'bug' when using "subplot" + "imagesc"? #2

Hi,

Does anybody know if Matlab7 has a 'bug' when using
"subplot" + "imagesc"? 

I use to work with Matlab6.5 and using "subplot" + "imagesc"
together in the same Figure worked absolutely fine:

=======================================
a) all subplots where of the same size, 
b) the distances between them was the appropiate, 
c) and the size of the colorbar was perfect and the same for
all subplots. 
=======================================

However I am now using Matlab7 and to my surprise using
"subplot" + "imagesc" together is not working as it should do:

=======================================
a) subplots are of different sizes!
b) the distances between them is too big, 
c) the size of the colorbar is different for each subplot
(sometimes too big, sometimes too small). 
=======================================

Any idea about what is going on!!

Cheers,

Ser.

0
serxyz1 (3)
1/17/2008 5:28:01 PM
comp.soft-sys.matlab 211265 articles. 25 followers. lunamoonmoon (257) is leader. Post Follow

4 Replies
465 Views

Similar Articles

[PageSpeed] 22

maybe you could give us some code bits to just CAP an 
double check?
0
1/17/2008 9:31:02 PM
True. Try to do the next bit in R13 (Matlab6.5) and R14
(Matlab7), save the figures (eg. as FigureR13 and FigureR14)
and compare how they differ:

==================
X=rand(180,360);
figure(1)
for k=1:12
    subplot(3,4,k)
    imagesc(X)
    colorbar
end
==================

Cheers,

Ser.

...................................
"Ashish Uthama" <ashishu.nop@ece.ubc.ca> wrote in message
<fmohem$lbv$1@fred.mathworks.com>...
> maybe you could give us some code bits to just CAP an 
> double check?

0
serxyz1 (3)
1/17/2008 11:00:21 PM
On Jan 17, 6:00 pm, "Ser xyz" <ser...@example.com> wrote:
> True. Try to do the next bit in R13 (Matlab6.5) and R14
> (Matlab7), save the figures (eg. as FigureR13 and FigureR14)
> and compare how they differ:

Ser -- I experienced the exact same problem when I transitioned from
6.5 to 7.1.  Eventually I gave up looking for options to imagesc or
image and manually positioned the windows using normalized
coordinates.  I show below a code fragment that should get you going.
My aim was to create a  4x4  grid of subplots, such that there was
almost no "white space" in between them.

I cut and pasted a few pieces of the code that are of greatest
relevance in a general
situation.  I can't guarantee it works perfectly, but I hope it helps
you out.

Jim

%----------------------------------------------------------------------------------------------------
figure(55);  % I chose a random figure number 55 just to get a figure
window open
fig = gcf;
rows = 4; cols = 4;  % Number of rows and columns in figure window
gridx = 16; gridy = 16;  % number of
positions = get_positions(rows,cols);  % see function below
close(55);

pHandles = zeros(1,rows*cols);
for i = 1:rows*cols   % cycle through all the subplots
  pHandles(i) = subplot('Position',positions(i,:));
  colormap(my_favorite_colormap);   % load a colormap if you've got
one
  middle_color = ceil(size(my_favorite_colormap,1)/2) + 1;  % may want
to ignore this
  image(zeros(gridx,gridy)+middle_color);  % may ignore this too
(specific to my app)
  axis off;
  % Note: the data I plot is a 3D matrix R(:,:,16)
  set(get(pHandles(i),'Children'),'CData',R(:,:,i));
  set(gca,'XTickLabel',[]);  % Suppress all tick markers
  set(gca,'YTickLabel',[]);
end

%---------------------------------------------------------------------------------
function positions = get_positions(rows,cols)
%---------------------------------------------------------------------------------
% Define an array of normalized position coordinates for the plot
squares
  positions = zeros(rows*cols,4);
  width = .245; height = width;  % height and width of each square
  for ibottom = 1:rows
    bottom = 1-ibottom*.25;
    for ileft = 1:cols
      left = (ileft-1)*.25;
      positions(4*(ibottom-1)+ileft,:) = [left bottom width height];
    end
  end
  return


0
1/17/2008 11:36:06 PM
The code:
X=rand(180,360);
figure(1)
for k=1:12
subplot(3,4,k)
imagesc(X)
colorbar
end

seems to work fine in MATLAB 7.4
Cheers,
cjkogan111
0
1/18/2008 3:32:13 AM
Reply: