我一直试着在指南中的等高线图旁输入一个颜色条而没有运气。
axes(handles.firstcontouraxes);
contourf(Y,X,z1)
title('First population');
set(gca,'YDir',yinverse,'XDir',xinverse,'clim',[cmin cmax]);
colorbar
Colorbar出现在最右上角,我希望它出现在空的第三轴框的位置:
a busy cat http://imageshack.com/a/img923/360/O7TiW3.png
当我尝试手动设置其位置时:
pos = get(gca,'position');
colorbar('location','manual','position',[pos(1)+pos(3)+.11 pos(2) .13 pos(4)]);
颜色栏显示在面板后面,部分可以在此图像的底部看到:
a busy cat http://imageshack.com/a/img924/2276/6a6xpj.png
当我试图将它带到前面时:
HC = get(gcf,'children'); % get the children handles
Hcol = findobj(HC,'tag','Colorbar');%find the colorbar handle
Jcol = find(HC==Hcol);% find its position in the list
HC(Jcol)=[];% delete it from list
HC = [Hcol;HC];% add it to the list top
set(gcf,'children',HC)% set the children in the new order
什么都没发生。
该程序使用标签代码如下:
有6个面板:tab1Panel,...,tab6Panel 和6个文本框:tab1text,...,tab6text
%% Tabs Code
% Settings
TabFontSize = 10;
TabNames = {'Gaussian','Tilt','Line scan','Area scan','Rename','Macros'};
FigWidth = 0.265;
% Tabs Execution
handles = TabsFun(handles,TabFontSize,TabNames);
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes ImpFitTwoFour7s3 wait for user response (see UIRESUME)
% uiwait(handles.MoFit_1_11);
% --- TabsFun creates axes and text objects for tabs
function handles = TabsFun(handles,TabFontSize,TabNames)
% Set the colors indicating a selected/unselected tab
handles.selectedTabColor=get(handles.tab1Panel,'BackgroundColor');
handles.unselectedTabColor=handles.selectedTabColor-0.1;
% Create Tabs
TabsNumber = length(TabNames);
handles.TabsNumber = TabsNumber;
TabColor = handles.selectedTabColor;
for i = 1:TabsNumber
n = num2str(i);
% Get text objects position
set(handles.(['tab',n,'text']),'Units','normalized')
pos=get(handles.(['tab',n,'text']),'Position');
% Create axes with callback function
handles.(['a',n]) = axes('Units','normalized',...
'Box','on',...
'XTick',[],...
'YTick',[],...
'Color',TabColor,...
'Position',[pos(1) pos(2) pos(3) pos(4)+0.01],...
'Tag',n,...
'ButtonDownFcn',[mfilename,'(''ClickOnTab'',gcbo,[],guidata(gcbo))']);
% Create text with callback function
handles.(['t',n]) = text('String',TabNames{i},...
'Units','normalized',...
'Position',[pos(3),pos(2)/2+pos(4)],...
'HorizontalAlignment','left',...
'VerticalAlignment','middle',...
'Margin',0.001,...
'FontSize',TabFontSize,...
'Backgroundcolor',TabColor,...
'Tag',n,...
'ButtonDownFcn',[mfilename,'(''ClickOnTab'',gcbo,[],guidata(gcbo))']);
TabColor = handles.unselectedTabColor;
end
% Manage panels (place them in the correct position and manage visibilities)
set(handles.tab1Panel,'Units','normalized')
pan1pos=get(handles.tab1Panel,'Position');
set(handles.tab1text,'Visible','off')
for i = 2:TabsNumber
n = num2str(i);
set(handles.(['tab',n,'Panel']),'Units','normalized')
set(handles.(['tab',n,'Panel']),'Position',pan1pos)
set(handles.(['tab',n,'Panel']),'Visible','off')
set(handles.(['tab',n,'text']),'Visible','off')
end
% --- Callback function for clicking on tab
function ClickOnTab(hObject,~,handles)
m = str2double(get(hObject,'Tag'));
for i = 1:handles.TabsNumber;
n = num2str(i);
if i == m
set(handles.(['a',n]),'Color',handles.selectedTabColor)
set(handles.(['t',n]),'BackgroundColor',handles.selectedTabColor)
set(handles.(['tab',n,'Panel']),'Visible','on')
else
set(handles.(['a',n]),'Color',handles.unselectedTabColor)
set(handles.(['t',n]),'BackgroundColor',handles.unselectedTabColor)
set(handles.(['tab',n,'Panel']),'Visible','off')
end
end
function varargout = MoFit_1_11_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
以下是指南的屏幕截图: hello http://imageshack.com/a/img923/9243/LZzfNj.jpg
我遇到了许多答案,但它们没有意义或不起作用 here,here和here。
以下是更新:
当我将轴放在面板外面时,我可以看到颜色条
hti http://imageshack.com/a/img923/3601/Voi6FX.jpg
但是一旦我将轴放在面板内,颜色条就会消失