In a GUI, I have several axes. How can I create differents custom data tips for each one?
This is just what I've tried so far: a function like this one right here. I've also tried two separates updatefunctions.
% --- Executes on mouse press over axes background.
function graph_5_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to graph_5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
datacursormode(handles.figMainWindow, 'off')VolDenPotVol = handles.VolDenPotVol;VolRend = handles.VolRend;Vol_x_mat = handles.Vol_x_mat;VolPartNumberHS = handles.VolPartNumberHS;VolConfigHS = handles.VolConfigHS;VolCompHS = handles.VolCompHS;% datacursormode(handles.graph_5, 'on')
% dcm = datacursormode(handles.graph_5);
datacursormode(handles.figMainWindow, 'on') %on
% dcm = datacursormode(gcf);
dcm = datacursormode(handles.figMainWindow);set(dcm,'UpdateFcn',@(t,e) myupdatefcn_graph5(t,e,VolDenPotVol,VolRend,Vol_x_mat, VolPartNumberHS, VolConfigHS, VolCompHS, 5) ); % --- Executes on mouse press over axes background.function graph_4_ButtonDownFcn(hObject, eventdata, handles)% hObject handle to graph_4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)datacursormode(handles.figMainWindow, 'off')VolDenPotPeso = handles.VolDenPotPeso;VolRend = handles.VolRend;Vol_x_mat = handles.Vol_x_mat;VolPartNumberHS = handles.VolPartNumberHS;VolConfigHS = handles.VolConfigHS;VolCompHS = handles.VolCompHS;% datacursormode(handles.graph_5, 'on')% dcm = datacursormode(handles.graph_5); datacursormode(handles.figMainWindow, 'on') %on% dcm = datacursormode(gcf);dcm = datacursormode(handles.figMainWindow);set(dcm,'UpdateFcn',@(t,e) myupdatefcn_graph5(t,e,VolDenPotPeso,VolRend,Vol_x_mat, VolPartNumberHS, VolConfigHS, VolCompHS, 4) );%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function txt = myupdatefcn(~,event,xdata,ydata,x_mat, PartNumberHS, ConfigHS, Comp, graph)pos = get(event,'Position');dts = get(event.Target,'Tag');[~,j]= find( xdata==pos(1) & ydata==pos(2) );% D = pdist2(pos(:)',[xdata(:) ydata(:)]);
% [~,j] = min(D);
% xdata(1,:) = xdata(1,:) / 1000;
% j=j(1);
switch graph case 5 txt = {dts,... ['Densidade de Potência: ', num2str(pos(1)), ' [kW/dm³]'],... ['Rendimento: ', num2str(100 * pos(2)), ' [%]'],... ['Frequência de Chaveamento: ', num2str(xdata(1,j)), ' [Hz]' ],... ['Material do Indutor: ', x_mat{j}]... ['Dissipador: ', PartNumberHS{j}]... ['Comprimento do Dissipador: ', num2str(Comp{j}), '[dm]']... ['Configuração: ', ConfigHS{j}]}; case 4 txt = {dts,... ['Densidade de Potência: ', num2str(pos(1)), ' [kW/kg]'],... ['Rendimento: ', num2str(100 * pos(2)), ' [%]'],... ['Frequência de Chaveamento: ', num2str(xdata(1,j)), ' [Hz]' ],... ['Material do Indutor: ', x_mat{j}]... ['Dissipador: ', PartNumberHS{j}]... ['Comprimento do Dissipador: ', num2str(Comp{j}), '[dm]']... ['Configuração: ', ConfigHS{j}]}; endend
However, I get this problem when I try to click on the second plot.
Best Answer