Hi, I am developing a GUI in matlab. In my GUI there is an axis and an option to analyze data plotted on that axis. But to do that I need semi-transparent uipanels on top of the axis so that users can see the part of axis that is going to be analysed including the grids. Since matlab doesn't allow semi-transparent uipanels, I found a work around for completely transparent uipanels on undocumented matlab. As I can easily make axis transparent by setting it's Color property to 'none', I decided to make the uipanels under it, but no matter if I create the uipanels before or after creating the axis it always appears on top, I know this is how matlab does it, i.e. uipanels and uicontrols always remains on top of the axis, but I am wondering is there any hack/work-around that I can use to make the uipanel appear under the axis? Here is an example code of what I am trying:
F = figure;Panel1 = uipanel('Parent',F,'BackgroundColor','y','Units','normalized','Position',[0 0 1 1]);Panel2 = uipanel('Parent',Panel1,'BackgroundColor','g','Units','normalized','Position',[0.25 0.25 0.5 0.5]);Axes1 = axes('Parent',Panel1,'GridColorMode','manual','GridColor','k','XGrid','on','YGrid','on',... 'GridLineStyle','--','NextPlot','add','Units','normalized','Position',[0 0 1 1]);T = 1:1:10;V = 10*rand(1,10);PLot1 = plot(T,V,'Parent',Axes1);Axes1.Color = 'none';
What I get is
I want this Panel2 (green coloured) to appear under the axis not on top of it. Is there any way this can be achieved?
I also tried another way of setting the BackgroundColor property of uipanel to transparent using the trick from undocumented matlab, and then place an axis on top of that uipanel. But doing so makes the uipanel opague back again. Here is the code for that:
F = figure;Panel1 = uipanel('Parent',F,'BackgroundColor','y','Units','normalized','Position',[0 0 1 1]);Panel2 = uipanel('Parent',Panel1,'BackgroundColor','g','Units','normalized','Position',[0.25 0.25 0.5 0.5]);Panel3 = uipanel('Parent',Panel1,'BackgroundColor','r','Units','normalized','Position',[0 0 1 1]);Axes1 = axes('Parent',Panel3,'GridColorMode','manual','GridColor','k','XGrid','on','YGrid','on',... 'GridLineStyle','--','NextPlot','add','Units','normalized','Position',[0 0 1 1]);T = 1:1:10;V = 10*rand(1,10);PLot1 = plot(T,V,'Parent',Axes1);Axes1.Color = 'none';% Making Panel3 Transparent
jPanel = Panel3.JavaFrame.getPrintableComponent;jPanel.setOpaque(false)jPanel.getParent.setOpaque(false)jPanel.getComponent(0).setOpaque(false)jPanel.repaint
And the result of above code
If there is any way I can make the uipanel appear under the axis then please let me know, any help will be highly appriciated. Thank you 🙂
Best Answer