How to insert a colorcloud into a subplot

4 ビュー (過去 30 日間)
emami.m
emami.m 2019 年 3 月 9 日
コメント済み: emami.m 2019 年 3 月 9 日
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;

採用された回答

Cris LaPierre
Cris LaPierre 2019 年 3 月 9 日
編集済み: Cris LaPierre 2019 年 3 月 9 日
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 件のコメント
Cris LaPierre
Cris LaPierre 2019 年 3 月 9 日
編集済み: Cris LaPierre 2019 年 3 月 9 日
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 2019 年 3 月 9 日
I appreciate your reply, that is exactly what I was looking for.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by