drawrectangle not working consistently, help!
Mostrar comentarios más antiguos
I am using drawrectangle in an app so the user can interactively draw region of interest. It is not working consistently. Sometimes it works fine, but sometimes it draws the region with a offset in -x direction. I cannot figure out why it works sometimes and somstimes it doesn't. Here is a snippet of my code I am using to get the roi.
function [roi] = selectDataPoints(app,tab)
delete(findall(app.([tab 'UIAxes']), 'Type', 'images.roi.Rectangle'))
originalTitle = get(app.([tab 'UIAxes']).Title, {'String', 'Color'});
set(app.([tab 'UIAxes']).Title, 'String', 'Draw rectangle around region to clip.', 'Color', 'r')
pan(app.([tab 'UIAxes']), 'off') %turn off panning so the interaction doesn't drag the data.
zoom(app.([tab 'UIAxes']),'off')
roi = drawrectangle(app.([tab 'UIAxes']),'StripeColor','r','InteractionsAllowed','none');
% Return original title
set(app.([tab 'UIAxes']).Title, 'String', originalTitle{1}, 'Color', originalTitle{2})
end
10 comentarios
Benjamin Kraus
el 3 de Dic. de 2020
This looks like it could be a question for MathWorks Technical Support.
- What release of MATLAB are you using?
- How far off in the x-direction is the region? A few pixels, or tens of pixels (or more)?
meghannmarie
el 3 de Dic. de 2020
Editada: meghannmarie
el 3 de Dic. de 2020
Adam Danz
el 3 de Dic. de 2020
What type of axes are you using / how did you produce the map?
meghannmarie
el 3 de Dic. de 2020
Adam Danz
el 3 de Dic. de 2020
This will be difficult to troubleshoot without being able to reproduce the problem.
Perhaps you could attach the app and instructions on how to reproduce the problem or maybe it would be easier to recreate it using uifigure/uiaxes.
I'm curious what ylim returns and what rect_pos and roi_pos are.
meghannmarie
el 3 de Dic. de 2020
meghannmarie
el 3 de Dic. de 2020
Some observations,
- When I copy the plot to a regular figure/axes (using copyUIAxes from the file exchange), drawrectangle works without problems.
- When I copy the uiaxes to a uifigure outside of app designer I get the same problems as we're experiencing in AppDesigner where sometimes it works and sometimes it doesn't.
- In AppDesigner and within an external UIFigure, drawrectangle is horribly slow and does not show the rectangle borders immediately. It's so slow that I would never use it in AppDesigner or a uifigure. I think this giagantic lag is the cause of the problem. As evidence of that, if you hold the initial button-down in place, slowly drag, and then hold the mouse button in the final destination until the rectangle appears, and then let go of the mouse button, the problem goes away but it's replaced by an unreasonable amount of waiting and wondering and frustration.
meghannmarie
el 3 de Dic. de 2020
Editada: meghannmarie
el 3 de Dic. de 2020
Adam Danz
el 3 de Dic. de 2020
Questions addressed in my answer below.
Respuesta aceptada
Más respuestas (2)
Christian Wrobel
el 5 de Feb. de 2021
0 votos
I had the same Problem, when I was using the AppDesigner (Matlab 2019a). I used a GridLayout to organize the axes and some surrounding UI-Objects within a tab. I've found out, that the padding of the GridLayout of the Tab was causing the Offset (Parent of axes). I changed the padding to [0,0,0,0] and the offset was gone. When I increased the padding of GridLayout the offset got even worse. Hope, this may help you.
Best Christian
Jonas
el 25 de Sept. de 2024
is this still an issue? I remember having also problems with that, but at the moment, I cannot replicate the problem in 2022a
f=uifigure; ax=uiaxes(f)
drawrectangle(ax)
seems to work just fine
1 comentario
DGM
el 25 de Sept. de 2024
I'm curious as to what version the ROI tools were even usable at all in a uifigure. As of R2019b, besides the extreme lag, the context menu doesn't even work in a uifigure. If I had to rely on release notes, I'd have to assume they're still not completely functional in a uifigure.
I'd try MATLAB online, but it's not loading for me today again.
Categorías
Más información sobre Ground Truth Labeling en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

