こんにちは、contourf プロットでデータヒントを編集できるように関数を作成しました。ポジションを取ることはできますが、問題はレベル (結果) も編集できないことです。
「pos = get(event_obj,'Position');」のような位置を取ることができます。
レベル(結果)を取ることができるmatlabのコマンドはありますか?
良い解決策は次のとおりです。
等高線図の後、次のように書きます。
dcm = datacursormode(gcf);
datacursormode on;
set(dcm, 'updatefcn',@perso_datacursor)
次に、この関数を作成します。
function output_txt = perso_datacursor( obj,event_obj)
dataIndex = get(event_obj,'DataIndex');
pos = get(event_obj,'Position');
h=get(event_obj,'Target');
X=get(h,'XData');
Y=get(h,'YData');
Z=get(h,'ZData');
idx_x=find(X==pos(1));
idx_y=find(Y==pos(2));
Level=Z(idx_y,idx_x);
output_txt = {[ 'X',num2str(pos(1),4)],...
[ 'Y',num2str(pos(2),4)],...
[ 'Z',num2str(Level)]};
end
また、輪郭のレベル (結果) もあります。