Hi,
I understand that you're using the meshCanopy1 function inside a GUI with multiple axes, and you're noticing that the histogram (imhist) and image display (imshow) stop rendering correctly after using meshCanopy1.
I assume that your GUI is built with GUIDE and that you have dedicated axes for displaying the image, histogram, and mesh plot.
In order to fix the issue of losing axes content and interaction, you can follow the below steps:
- Understand the source of the issue: The meshCanopy1 function likely changes the figure or axes context internally (such as by calling figure or implicitly switching axes). This disrupts the active axes in your GUI and causes MATLAB to draw in a new or unintended figure.
- Re-focus axes before plotting: Before each visual element is plotted (e.g., the image, histogram, and mesh), make sure that the GUI explicitly tells MATLAB which axes to use. This prevents plotting from being redirected to an unintended axes or figure.
- Clear axes before plotting: Use a method to clear the content of the axes before new content is plotted. This ensures the axes remains consistent and ready for the next image or plot.
- Prevent meshCanopy1 from altering figures: If you can modify the meshCanopy1 function, ensure it does not call figure internally or that it accepts an axes handle to draw in. Alternatively, make sure all plotting inside it is constrained to the correct GUI axes.
- Check GUIDE settings: In GUIDE’s property inspector, ensure the NextPlot property of each axes is set appropriately. For GUI work, it’s often best to use values like replacechildren to allow re-plotting without erasing the axes itself.
Hope this helps!