CLA to Clear Out Axes Not Working in Slider Callback Function
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello Everyone!
I am developing an app to process and analyze vasodilation data and I have spent several days trying to fix the following two issues. Your help will be appreciated.
1) I am using a slider to go from one frame of the dataset to another. The slider updates all the graphs shown in the screenshot below. At first, the app updates the graphs pretty fast but the more I use the slider to update the graphs, the slower the app gets. I think that this is happening because the graphs are not cleared out before they are updated by the slider. You can see that this on the top graph in the screenshot below. The red markers of previously displayed graphs (highlighted with magenta) are not cleared out after choosing a different frame. I have tried to use cla in the callback function before plotting the new graphs but this does not work. Any insights about what I can do to clear out the graphs before plotting the new ones with the slider?
2) The second issue is a minor one but I would like to get it fixed. Every time I use the slider to go from one frame to another, the colorbar and the x and y titles of the graph on the left are shown on the left lower corner of the screen before being properly shown in the right place (See what is highlighted with magenta in the screenshot below) How can I fix this?
If you need to see my script, let me know. I am more than happy to share it or share parts of it. Thank you so much for your attention!
댓글 수: 2
Cris LaPierre
2023년 6월 17일
How are you clearing your axes? Yes, please share your code. It is much easier to help if we can see what you are doing.
채택된 답변
Walter Roberson
2023년 6월 17일
If you have performance issues, then you should be re-working your graphics a fair bit.
For performance, create your axes and titles and graphic objects once, and then as you go through the loop, update the graphics objects as needed. That might be something like
h = plot(nan,nan); %initialize
while true
stuff
set(h, 'XData', new_x_values, 'YData', new_y_values);
drawnow limitrate
end
Creating new graphics objects is a lot more expensive than updating the properties of existing graphics objects.
댓글 수: 3
Walter Roberson
2023년 6월 17일
The uiaxes, uipanel, various uilabel -- all of those can be created in advance, possibly set Visible off at the beginning. Then as you get new data, update only the properties needed
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!