How to delete a line from UIAxes using plotedit in the menu bar with app designer.

4 ビュー (過去 30 日間)
mg
mg 2024 年 7 月 24 日
コメント済み: mg 2024 年 7 月 25 日
Hi,
I want to edit a line from UIAxes using plotedit in the menu bar with app designer. I used callback "Plot_editMenuSelected" But it is not working.
function Plot_editMenuSelected(app, event)
plotedit(app.UIAxes,'on')
end
Can someone please tell me solution?
Thanks
  1 件のコメント
Ashutosh Thakur
Ashutosh Thakur 2024 年 7 月 24 日
Hi @mg,
It is very difficult to know what is the core issue without access to the complete codebase. Can you try to upload MLAPP as well?
Thanks

サインインしてコメントする。

採用された回答

Avni Agrawal
Avni Agrawal 2024 年 7 月 24 日
編集済み: Avni Agrawal 2024 年 7 月 24 日
Hi @mg,
I understand that you are trying to enable plot editing for a UIAxes in App Designer using the `plotedit` function. However, `plotedit` is not directly applicable to `UIAxes` in App Designer. Instead, you may need to use other approaches to allow editing or modifying plots in `UIAxes`.
Here is a possible solution using a context menu to enable editing of plot properties:
1. Create a context menu for the `UIAxes`.
2. Add menu items to the context menu for editing options.
3. Define callbacks for these menu items to allow editing of plot properties.
Step 1: Create a Context Menu
In the `startupFcn` of your app, create a context menu and assign it to the `UIAxes`.
function startupFcn(app)
% Create context menu
c = uicontextmenu(app.UIFigure);
% Create menu items
uimenu(c, 'Text', 'Edit Line', 'MenuSelectedFcn', @(src,event)editLine(app));
% Assign context menu to UIAxes
app.UIAxes.UIContextMenu = c;
end
Step 2: Define the Callback Function
Define the `editLine` function to allow editing of the line properties.
function editLine(app)
% Get the current line object
lineHandle = findobj(app.UIAxes, 'Type', 'Line');
if isempty(lineHandle)
uialert(app.UIFigure, 'No line found in the axes.', 'Error');
return;
end
% Example: Change line color
newColor = uisetcolor;
if length(newColor) == 3
lineHandle.Color = newColor;
end
end
I hope this helps!
  1 件のコメント
mg
mg 2024 年 7 月 25 日
Hi Avni ,
I tried as your method. It works well. but I modified the callback function and added a function called plotedit, but I could not edit the lines of the graphs on UIAxes. Perhaps plotedit does not work with UIAxes. Thank you so much.
function Plot_editCheckBoxValueChanged(app, event)
lineHandle = findobj(app.UIAxes)
plotedit(lineHandle,'on')
% Get the current line object
% lineHandle = findobj(app.UIAxes, 'Type', 'Line');
%
% if isempty(lineHandle)
% uialert(app.GUI_PlotUIFigure, 'No line found in the axes.', 'Error');
% return;
% end
%
% % Example: Change line color
% newColor = uisetcolor;
% if length(newColor) == 3
% lineHandle.Color = newColor;
% end
end

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by