How to Display in multiple axes text and images using UIPanel instead of figure ?

2 views (last 30 days)
Hi all !
I am looking for a way to plot multiples images and text in my app, i am using the code bellow to do so, it works just fine. However, the images and text are displayed on a figure, i want to do the same thing but on a UIpanel called in my app: app.ConverterSizingBenchmarkPanel
this is my code :
i am sure the problem occure in the first line with fh, but i am not sure how to do it .
Thank you for your precious answers
Lakhdar
fh = uipanel("Parent",app.ConverterSizingBenchmarkPanel); % << /!\ I THINK THE PROBLEM IS HERE /!\
axisPanelLeftUp = uipanel(fh, 'Position', [0 0.5 0.5 0.5], 'BackgroundColor', [1 1 1]);% Create a panel to hold the plot axis
leftUpAxis = axes(axisPanelLeftUp, 'Position', [0.1 0.1 0.8 0.8]); % Create a new axis on the panel
text(leftUpAxis,0, 1, sprintf('%.2f %s', 'Volume_x_Rth/Rth','L'), 'Fontsize',12,'FontWeight',"bold",'Color',[0.85 0.33 0.10])
set(axisPanelLeftUp,'handlevisibility','off', 'visible','on')
axisPanelLeftDown = uipanel(fh, 'Position', [0 0 0.5 0.5], 'BackgroundColor', [0 1 1]);% Create a panel to hold the plot axis
leftDownAxis = axes(axisPanelLeftDown, 'Position', [0.1 0.1 0.8 0.8]); % Create a new axis on the panel
text(leftDownAxis,0, 1, sprintf('%.2f %s', 'Volume_x_Rth/Rth','L'), 'Fontsize',12,'FontWeight',"bold",'Color',[0.85 0.33 0.10])
axisPanelRightUp = uipanel(fh, 'Position', [0.5 0.5 0.5 .5], 'BackgroundColor', [1 1 1]); % Create a different panel to hold the button and a second axis
rightUpAxis = axes(axisPanelRightUp,'Position', [0 0 1 1]); % Create an axis on the right panel
imshow("Amorphous_Inductor.jpg",'Parent',rightUpAxis');
axisPanelRightDown = uipanel(fh, 'Position', [0.5 0 0.5 .5], 'BackgroundColor', [1 1 1]);
rightDownBottomAxis = axes(axisPanelRightDown,'Position', [0 0 1 1]);% Create pushbuttons to plot data
imshow("Filtring_Capacitor.png",'Parent',rightDownBottomAxis');

Accepted Answer

Adam Danz
Adam Danz on 20 Sep 2020
Edited: Adam Danz on 21 Sep 2020
fh should be your app's figure handle.
fh = app.UIFigure; % or whatever your fig handle is.
or perhaps you want to assign the parent-panel to the app in which case you still need to use the app's figure handle.
fh = uipanel("Parent",app.UIFigure; % or whatever your fig handle is.
but then you're missing other stuff like the panel's position property, etc.
  8 Comments
Khalala Mamouri
Khalala Mamouri on 21 Sep 2020
Sorry to confuse you. YES ! it work perfectly, What happens is that i was creating new UIPanelon top of the already existing one.
OK so let me share my code for the next user :
leftUpAxis = axes(app.ConverterSizingBenchmarkPanel, 'Position', [0 0.5 0.5 0.5]); % Create a new axis on the panel
leftUpAxis.XColor='none'; % HIdes the axes because later i will show text here
leftUpAxis.YColor='none'; % Hides the axes because later i will show text here
Police = 9; %
%% Writing text (exemple)
text(leftUpAxis,0, 1, sprintf(' %s ', 'Inductor Benchmark'), 'Fontsize',Police,'FontWeight',"bold",'Color',[0.0 0.45 0.74])
%% show an image (exemple2)
rightDownBottomAxis = axes(app.ConverterSizingBenchmarkPanel,'Position', [0.5 0 0.5 .5]);% Create pushbuttons to plot data
imshow("Filtring_Capacitor.png",'Parent',rightDownBottomAxis');

Sign in to comment.

More Answers (0)

Categories

Find more on Develop uifigure-Based Apps in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!