Scaling pcolor graphics on subplots
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm trying to subplot (by collumns) a bar, a pcolor, 8 pcolors, one plot. Problem is: the matrixes for the 8 pcolors are being plotted way to small. I'd like to make them bigger, filling the whole "cell" of the subplot (I'm getting something like I tenth of it!).
My code goes something like this:
cmap = [1 0 0;0.5,0.5,0.5;0,0,1];
A = ones(1,10) * 5;
B = zeros(50);
for a = 1:10
diagonal = [ones(1,a-1) zeros(1,10-a+1)];
C{a} = diag(diagonal, 0);
end
D_base = [10 10 9 8 7 5 3 2 1 0];
for a = 1:10
D{a} = D_base + rand(1,10);
end
% Plotting functions
x = [1 2 9 10 17 18 25 26];
%%First block plotting
subplot(4,8,[1 26]), bar(A)
xlim([0.3 10.8])
ylim([0 13])
xlabel('Group')
ylabel('Species')
%%Second block plotting
y = [x(1)+2 x(8)+2]; %Defining positions
h = subplot(4,8,y), pcolor(B) ;
xlim([1 length(B)]); % Limits X-axis
ylim([1 length(B)]); % Limits Y-axis
axis off;
colormap(cmap);
caxis([-1 1])
axis ij;
title(B)
set(get(gca, 'Title'), 'Color', [0.166 0 0]);
%%Third block plot
x = x + 4; %Defining positions
for a = 1:8 % I know I'm not plotting the whole thing
h = subplot(4,8,x(a)), pcolor(C{a}) ;
xlim([1 length(B)]);
ylim([1 length(B)]);
axis off;
colormap(cmap);
caxis([-1 1])
axis ij;
title(a)
set(get(gca, 'Title'), 'Color', [a*0.1 0 0]);
end
%%Fourth block plotting
x = [7 32]; % Defining positions
% Collor defining
cmap = zeros(8,3);
cmap(1) = 0.3;
aux = [0.1 0 0];
%ploting
for a = 2:8
cmap(a,:) = cmap(a-1,:) + aux;
end
for a = 1:8
subplot(4,8,x), plot(D{a},'Color',cmap(a,:))
hold on
end
Any ideas on how to make the C subplots larger?
0 Kommentare
Akzeptierte Antwort
Fangjun Jiang
am 16 Okt. 2011
If you comment out the following two lines in the "Third block plot". The figure is about right.
xlim([1 length(B)]);
ylim([1 length(B)]);
Weitere Antworten (1)
Image Analyst
am 16 Okt. 2011
Try adjusting the Position or OuterPosition property of the plot just after you call pcolor. I'd also like you to explain why you're using pcolor at all, instead of image(), because I don't like the fact that each tile doesn't represent one pixel and you have one less little tile across than you have pixels across.
2 Kommentare
Image Analyst
am 17 Okt. 2011
Well I'd suggest not using pcolor() and using image() instead, the main problem being that the color of each tile in pcolor is not directly related to the value of the pixel.
Getting the right position settings for each plot will be tedious so I'll leave that to you. The images will be pretty tiny though so I wonder how useful they'll be. If it were me I'd create another figure for your array of images so they'll be big enough to actually see.
Siehe auch
Kategorien
Mehr zu Blue finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!