Reputation: 3616
I have 4 figures I've done in Matlab. The problem is that there are some white spaces but I don't know how to remove them from the figures. In the below figures there are some white spaces I want to remove. Also I want to adjust the color bar to start and end with the images frames. So if anyone could please assist me. Here are the 4 figures that show up from the below script, I've edited them to explain the desired figures I want. This is the code I used:
load('D:\Deakin\My papers\Hussein\MatFiles\k640_Sensor_Lights_On_2000mm-pgms.mat','stats');
ax(1)=subplot(1,2,1);imagesc(stats.std,[0 18]);colormap(jet(256)); title('(a)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+550 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\x640_Sensor_Lights_On_2000mm-pgms.mat','stats');
ax(2)=subplot(1,2,2);imagesc(stats.std,[0 18]);colormap(jet(256)); title('(b)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+550 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
h=colorbar('SouthOutside');
set(h, 'Position', [.1 .05 .8150 .05]);
for i=1:2
pos=get(ax(i), 'Position');
set(ax(i), 'Position', [pos(1) 0.1+pos(2) pos(3) 0.8*pos(4)]);
end;
set(findobj('type','axes'),'FontSize',20);
set(gcf,'units','normalized','outerposition',[0 0 1 1]);
figure();
load('D:\Deakin\My papers\Hussein\MatFiles\k640_Sensor_Lights_On_0500mm-pgms.mat','stats');
ax(1)=subplot(2,5,1);imagesc(stats.nlvls,[0 16]);colormap(jet(256)); title('(a)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+640 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\k640_Sensor_Lights_On_1000mm-pgms.mat','stats');
ax(2)=subplot(2,5,2);imagesc(stats.nlvls,[0 16]);colormap(jet(256)); title('(b)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+640 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\k640_Sensor_Lights_On_1500mm-pgms.mat','stats');
ax(3)=subplot(2,5,3);imagesc(stats.nlvls,[0 16]);colormap(jet(256)); title('(c)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+640 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\k640_Sensor_Lights_On_2000mm-pgms.mat','stats');
ax(4)=subplot(2,5,4);imagesc(stats.nlvls,[0 16]);colormap(jet(256)); title('(d)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+640 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\k640_Sensor_Lights_On_2500mm-pgms.mat','stats');
ax(5)=subplot(2,5,5);imagesc(stats.nlvls,[0 16]);colormap(jet(256)); title('(e)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+640 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\x640_Sensor_Lights_On_0500mm-pgms.mat','stats');
ax(6)=subplot(2,5,6);imagesc(stats.nlvls,[0 16]);colormap(jet(256)); title('(f)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+640 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\x640_Sensor_Lights_On_1000mm-pgms.mat','stats');
ax(7)=subplot(2,5,7);imagesc(stats.nlvls,[0 16]);colormap(jet(256)); title('(g)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+640 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\x640_Sensor_Lights_On_1500mm-pgms.mat','stats');
ax(8)=subplot(2,5,8);imagesc(stats.nlvls,[0 16]);colormap(jet(256)); title('(h)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+640 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\x640_Sensor_Lights_On_2000mm-pgms.mat','stats');
ax(9)=subplot(2,5,9);imagesc(stats.nlvls,[0 16]);colormap(jet(256)); title('(i)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+640 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\x640_Sensor_Lights_On_2500mm-pgms.mat','stats');
ax(10)=subplot(2,5,10);imagesc(stats.nlvls,[0 16]);colormap(jet(256)); title('(j)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+640 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
h=colorbar('SouthOutside');
set(h, 'Position', [.1 .05 .8150 .05]);
for i=1:10
pos=get(ax(i), 'Position');
set(ax(i), 'Position', [pos(1) 0.1+pos(2) pos(3) pos(4)]);
end;
set(findobj('type','axes'),'FontSize',20);
set(gcf,'units','normalized','outerposition',[0 0 1 1]);
figure();
load('D:\Deakin\My papers\Hussein\MatFiles\k640_Sensor_Heater_On_1000mm-pgms.mat','stats');
ax(1)=subplot(2,2,1);imagesc(stats.entropy,[0 4]);colormap(jet(256)); title('(a)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+640 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\k640_Sensor_Lights_On_1000mm-pgms.mat','stats');
ax(2)=subplot(2,2,2);imagesc(stats.entropy,[0 4]);colormap(jet(256)); title('(b)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+640 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\x640_Sensor_Heater_On_1000mm-pgms.mat','stats');
ax(3)=subplot(2,2,3);imagesc(stats.entropy,[0 4]);colormap(jet(256)); title('(c)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+640 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\x640_Sensor_Lights_On_1000mm-pgms.mat','stats');
ax(4)=subplot(2,2,4);imagesc(stats.entropy,[0 4]);colormap(jet(256)); title('(d)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+640 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
h=colorbar('SouthOutside');
set(h,'XTick',0:4);
set(h, 'Position', [.1 .05 .8150 .05]);
for i=1:4
pos=get(ax(i), 'Position');
set(ax(i), 'Position', [pos(1) 0.1+pos(2) pos(3) 0.8*pos(4)]);
end;
set(findobj('type','axes'),'FontSize',20);
set(gcf,'units','normalized','outerposition',[0 0 1 1]);
figure();
load('D:\Deakin\My papers\Hussein\MatFiles\x640_Sensor_Lights_On_2500mm_with_interference_distance_1600-pgms.mat','stats');
ax(1)=subplot(1,3,1);imagesc(stats.nlvls,[0 16]);colormap(jet(256)); title('(a)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+550 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\x640_Sensor_Lights_On_2500mm_with_interference_distance_1350-pgms.mat','stats');
ax(2)=subplot(1,3,2);imagesc(stats.nlvls,[0 16]);colormap(jet(256)); title('(b)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+550 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
load('D:\Deakin\My papers\Hussein\MatFiles\x640_Sensor_Lights_On_2500mm_with_interference_distance_1100-pgms.mat','stats');
ax(3)=subplot(1,3,3);imagesc(stats.nlvls,[0 16]);colormap(jet(256)); title('(c)');
set(findobj('type','text'),'FontSize',20);
h=get(gca,'Title');
P = get(h,'Position');
set(h,'Position',[P(1) P(2)+550 P(3)],'FontSize',20);
set(gca,'FontSize',20);
set(gca,'DataAspectRatio',[1 1 1]);
axis off;
h=colorbar('SouthOutside');
set(h, 'Position', [.1 .05 .8150 .05]);
for i=1:3
pos=get(ax(i), 'Position');
set(ax(i), 'Position', [pos(1) 0.1+pos(2) pos(3) 0.8*pos(4)]);
end;
set(findobj('type','axes'),'FontSize',20);
set(gcf,'units','normalized','outerposition',[0 0 1 1]);
figure();
Upvotes: 1
Views: 675
Reputation: 703
I am aware of two approaches:
subplot('position',[left bottom width height])
function allows to position a subplot anywhere in normalized coordinate frame.
convert the figure to *.eps
format and remove the space manually in some graphic software. This is best if you just need to prepare one figure for publication purposes.
Upvotes: 1