like i defiend it the dimensions to be 10 X 10n but the subplot is opening on the dimesions of the GUI i.e 50 x 10
Define limits of a subplot to fit in one axes widget in GUI
조회 수: 2 (최근 30일)
이전 댓글 표시
hi i have a GUI with only one axes widget that has a defined area on GUI. when i click ion my pushbutton to plot the sublpot with 3 rows and 1 column it plots outside the boundary of the axes widget defined earlier and occupies the space in the gui.
any suggestion on how to make it work properly on the pre-defined dimensions of my gui.
alternatively how can i open this subplot window in a different dialog box...like the figure window...
답변 (1개)
Walter Roberson
2011년 11월 24일
subplot() is relative to a figure, not to an axes. You cannot use subplot() to partition an axes: if you try then subplot() will delete the existing axes so that there are no overlaps.
If you want to plot on different within a particular rectangular subsection of a figure, consider creating a uipanel() around the area to be plotted in. You can then subplot() within the uipanel, by specifying the uipanel handle as the Parent property in the subplot() command. For example:
uip = uipanel('Position',[0.75 0.75 0.25 0.25]);
ax1 = subplot(1,3,1, 'Parent', uip);
plot(ax1, x1, y1);
ax2 = subplot(1,3,2, 'Parent', uip);
hist(ax2, x2, y2);
ax3 = subplot(1,3,3, 'Parent', uip);
surf(ax3, z3);
댓글 수: 1
Thomas Dixon
2020년 2월 18일
I have implemetned you code but i cant get the axis labels and titles to work, I am new to the GUI plots so any comment on my attempt is helpful as such I have included some commnted out ideas I had which you may think will work better.
function [fig] = slidersetup(data_struct,N)
fig = uifigure;
fig.WindowState = 'maximized';
sld_pnl = uipanel(fig,'Position',[10 10 540 50]);
ax_pnl = uipanel(fig,'Position',[10 60 1800 1000]);
val_pnl = uipanel(fig,'Position',[550 10 700 50]);
% ax=uiaxes(fig,'Position',[10 60 400 400])
ax_pnl.AutoResizeChildren = 'off'
%
ax1 = subplot(2,2,[1 2], 'Parent', ax_pnl);
[sx,sy] = meshgrid(data_struct{1}.f_meas(1300:1400),1:N);
set(gcf,'renderer','zbuffer')
s=surf(ax1,sx*10^-9,sy,data_struct{1}.I_f_meas(1300:1400,1:N)'.*10^6);
s.LineStyle = 'none';
s.FaceColor = 'interp';
view([10 -20 20]);
% ax=gca;
% ax.FontSize=22;
xlabel('Frequency (GHz)');
ylabel('Node (N)');
zlabel('Current (uA)');
ax2 = subplot(2,2,3, 'Parent', ax_pnl);
plot(ax2,1:N,data_struct{1}.phase(1,:))
ax3 = subplot(2,2,4, 'Parent', ax_pnl);
plot(ax3,1:N-1,data_struct{1}.phase_diff(1,:),'o')
sld = uislider(sld_pnl,'Position',[10 30 180 3],'ValueChangedFcn',@(sld,event) PlotUpdate(sld,ax_pnl,sld_pnl,data_struct,N));
sld.Limits = [1 200];
sld.Value = 1;
sld.MajorTicks = [1 50 100 150 200]
tbox = uieditfield(val_pnl,'numeric','Position',[550 10 565 40],'ValueChangedFcn',@(tbox,event) numberChanged(tbox,sld,ax_pnl,sld_pnl,data_struct,N));
tbox_val = uieditfield(sld_pnl,'Position',[200 10 215 40],'Value',[num2str(sld.Value),' GHz']);
end
function PlotUpdate(sld,ax_pnl,sld_pnl,data_struct,N)
sld.Value = round(sld.Value);
%set(h, 'YData', data_struct{1}.phase(sld.Value*10,:))
% plot(ax,1:N,data_struct{1}.phase(10*sld.Value,:))
ax2 = subplot(2,2,3,'Parent',ax_pnl);
plot(ax2,1:N,data_struct{1}.phase(sld.Value*10,:));
ax3 = subplot(2,2,4,'Parent',ax_pnl);
plot(ax3,1:N-1,data_struct{1}.phase_diff(sld.Value*10,:),'o');
% val_pnl.Children.tbox.String = [num2str(sld.Value*10),' GHz']
tbox_val = uieditfield(sld_pnl,'Position',[200 10 215 40],'Value',[num2str(sld.Value),' GHz']);
end
function numberChanged(tbox,sld,ax_pnl,sld_pnl,data_struct,N)
sld.Value = tbox.Value;
ax2 = subplot(2,2,3,'Parent',ax_pnl);
plot(ax2,1:N,data_struct{1}.phase(sld.Value*10,:));
ax3 = subplot(2,2,4,'Parent',ax_pnl);
plot(ax3,1:N-1,data_struct{1}.phase_diff(sld.Value*10,:),'o');
% val_pnl.Children.tbox.String = [num2str(sld.Value*10),' GHz']
tbox_val = uieditfield(sld_pnl,'Position',[200 10 250 50],'Value',[num2str(sld.Value),' GHz']);
end
Produces
Where clearly the surf plot axis arentl labelled
I would like to be able to do all the usual stuff I do with plots label, latex style set axis sizes turn grids on/off change the view etc.. is this possible on a UIpanel plot?
You can find the stuff I plot on the repository here:
any help is most welcome
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!