imshow border tight for subplot

5 ビュー (過去 30 日間)
Sukuchha
Sukuchha 2012 年 2 月 10 日
編集済み: Erik 2013 年 10 月 8 日
i can hide the grey border around the figure with setting;
iptsetpref('ImshowBorder','tight');
figure;Image = rand(1000,1000);
imshow(Image,[]), colormap jet;
How can i do the same if i am using subplot! iptsetpref doesnot seem to have any effect in subplot.
iptsetpref('ImshowBorder','tight');
figure;
subplot(1,2,1)
imshow(Image,[]), colormap jet;
subplot(1,2,2)
imshow(Image,[]), colormap jet;
  2 件のコメント
Sukuchha
Sukuchha 2012 年 2 月 10 日
i tried to format code, but some how it is not working !
Sukuchha
Sukuchha 2012 年 2 月 10 日
anyone?

サインインしてコメントする。

採用された回答

Sean de Wolski
Sean de Wolski 2012 年 2 月 10 日
Use subplott to generate axes handles for each individual subplot
h = subplott(3,3);
imshow('cameraman.tif','parent',h(6));
imshow('pout.tif','parent',h(2));
Note, the images will not be tight in both dimensions unless the figure is turned into the correct shape manually and all images are the same shape.
E.g.:
set(gcf,'units','pix')
set(gcf,'position',[200 200 800 800])
With the figure from above. Where subplott.m is:
function [hA] = subplott(nr,nc)
%function to return a figure handle and axes handles for tight subplots
%
%Inputs:
% r: number of rows
% c: number of columns
%
%Outputs:
% hA: axes handles to subplots (styled order, i.e. rows first then columns)
%
%See Also: subplot imshow
%
%Error Checking:
assert(nargin==2,'2 inputs expected');
assert(isscalar(nr)&&isscalar(nc));
%Other Constants:
rspan = 1./nr; %row span normalized units
cspan = 1./nc; %not the tv channel
na = nr*nc; %num axes
%Engine
rlow = flipud(cumsum(rspan(ones(nr,1)))-rspan); %lower edge
clow = cumsum(cspan(ones(nc,1)))-cspan;
[rg cg] = meshgrid(1:nr,1:nc); %grids
hA = zeros(na,1);
figure;
for ii = 1:na
pos = [clow(cg(ii)) rlow(rg(ii)) cspan rspan]; %positions
hA(ii) = axes('units','norm','outerposition',pos,'position',pos); %build axes
end
end
  1 件のコメント
Sukuchha
Sukuchha 2012 年 2 月 10 日
thanxs heap ! Thats just awesome!

サインインしてコメントする。

その他の回答 (1 件)

Sean de Wolski
Sean de Wolski 2012 年 2 月 10 日
Instead of using subplot, build the axes directly:
figure('units','pixels','position',[200 200 800 400]); 5fig
axes('units','norm','outerposition',[0 0 0.5 1],'position',[0 0 0.5 1]) %left axes
imshow(rand(100),[])
axes('units','norm','outerposition',[0.5 0 0.5 1],'position',[0.5 0 0.5 1]) %right axes
imshow(imread('cameraman.tif'),[])
  2 件のコメント
Sukuchha
Sukuchha 2012 年 2 月 10 日
thanks Sean, it works wonderfully for two axes ! But i have around 12 axes, i dont want to write outerposition and position vector individually to each axes.
lets say i create a figure with
figure('units','normalized','outerposition',[0 0 1 1]);
is there a way to generate those outerposition and position vector for any arbitary division N.
Sean de Wolski
Sean de Wolski 2012 年 2 月 10 日
Sure! In fact that sounds like a good idea for a game of code golf! I'll get back to you on this later this afternoon.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by