How to insert a colorcloud into a subplot
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
emami.m
am 9 Mär. 2019
Kommentiert: emami.m
am 9 Mär. 2019
Hi there,
I was wondering how can I add a colorcloud graph into a subplot. I see that kind of graph in the Image Processing Toolbox / Color Thresholder app.
Here is the code that I use to insert different Images and graph into a figure:
Titles are not in the right position. Also the third plot overlape the 5th and sometimes make the 3rd in half size.
I appreciate your help.
RGB = imread('peppers.png');
grayImage = rgb2gray(RGB);
subplot(3, 3, 1);
imshow(RGB);
% Maximize the figure window.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Force it to display RIGHT NOW
drawnow;
caption = sprintf('Title 1');
title(caption, 'FontSize', 10);
axis image;
subplot(3, 3, 2);
imshow(grayImage);
drawnow;
caption = sprintf('Title 2');
title(caption, 'FontSize', 10);
axis image;
%hpanel = subplot(3, 3, 3);
hpanel = uipanel('Parent',gcf,'Position', [0.6, 0.6, 0.4, 0.4],'Tag','ui');
colorcloud(RGB,'rgb','Parent',hpanel);
drawnow;
title('Title 3', 'FontSize', 10);
subplot(3, 3, 4);
imshow(grayImage)
title('Title 4', 'FontSize', 10);
[pixelCount, grayLevels] = imhist(grayImage);
subplot(3, 3, 5);
bar(pixelCount);
title('Title 5', 'FontSize', 10);
xlim([0 grayLevels(end)]); % Scale x axis manually.
grid on;
0 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 9 Mär. 2019
Bearbeitet: Cris LaPierre
am 9 Mär. 2019
I'd probably set up all the plots, then add the uipanel last.
figure;
% Maximize the figure window.
set(gcf,'Visible','on','units','normalized','outerposition',[0 0 1 1])
RGB = imread('peppers.png');
grayImage = rgb2gray(RGB);
subplot(3, 3, 1);
imshow(RGB);
title('Title 1', 'FontSize', 10);
axis image;
subplot(3, 3, 2);
imshow(grayImage);
title('Title 2', 'FontSize', 10);
axis image;
subplot(3, 3, 3)
title('Title 3', 'FontSize', 10);
axis off
subplot(3, 3, 4);
imshow(grayImage)
title('Title 4', 'FontSize', 10);
[pixelCount, grayLevels] = imhist(grayImage);
subplot(3, 3, 5);
bar(pixelCount);
title('Title 5', 'FontSize', 10);
xlim([0 grayLevels(end)]); % Scale x axis manually.
grid on;
% Add uipanel last
hpanel = uipanel('Parent',gcf,'Position', [0.67, 0.7, 0.25, 0.2]);
colorcloud(RGB,'rgb','OrientationAxesColor','none','Parent',hpanel);
3 Kommentare
Cris LaPierre
am 9 Mär. 2019
Bearbeitet: Cris LaPierre
am 9 Mär. 2019
Sure. Specify the parent when creating suplot 4 to bring the focus back to the figure window instead of the UIpanel.
f = figure;
% Maximize the figure window.
set(gcf,'Visible','on','units','normalized','outerposition',[0 0 1 1])
RGB = imread('peppers.png');
grayImage = rgb2gray(RGB);
subplot(3, 3, 1);
imshow(RGB);
title('Title 1', 'FontSize', 10);
axis image;
subplot(3, 3, 2);
imshow(grayImage);
title('Title 2', 'FontSize', 10);
axis image;
ax=subplot(3, 3, 3)
title('Title 3', 'FontSize', 10);
axis off
% Add uipanel last
hpanel = uipanel('Parent',f,'Position', [0.67, 0.7, 0.25, 0.2]);
colorcloud(RGB,'rgb','OrientationAxesColor','none','Parent',hpanel);
subplot(3, 3, 4,'Parent',f);
imshow(grayImage)
title('Title 4', 'FontSize', 10);
[pixelCount, grayLevels] = imhist(grayImage);
subplot(3, 3, 5);
bar(pixelCount);
title('Title 5', 'FontSize', 10);
xlim([0 grayLevels(end)]); % Scale x axis manually.
grid on;
This allows you to create them sequentially.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Performance 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!