How to insert a colorcloud into a subplot

1 vue (au cours des 30 derniers jours)
emami.m
emami.m le 9 Mar 2019
Commenté : emami.m le 9 Mar 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;

Réponse acceptée

Cris LaPierre
Cris LaPierre le 9 Mar 2019
Modifié(e) : Cris LaPierre le 9 Mar 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 commentaires
Cris LaPierre
Cris LaPierre le 9 Mar 2019
Modifié(e) : Cris LaPierre le 9 Mar 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.
emami.m
emami.m le 9 Mar 2019
I appreciate your reply, that is exactly what I was looking for.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by