Zooming Into UIAxes Image Changes Axis Shape and Position: Why, and How Do I Fix?!
    10 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
I am developing a MATLAB App, and have an image in a UIAxes, with the following properties defined: 
        s1 = 512;
        s2 = 512;
        app.UIAxes_Image_Plot.XLim = [0,s1];
        app.UIAxes_Image_Plot.YLim = [0,s2];
        app.UIAxes_Image_Plot.ZLim = app.UIAxes_Image_Plot.XLim;
        app.UIAxes_Image_Plot.CameraPosition = [s1/2, s2/2, s1/2];
        app.UIAxes_Image_Plot.CameraTarget = [s1/2, s2/2, 0];
    daspect(app.UIAxes_Image_Plot, [1 1 1])
This plots the images well, and fill the whole defined axes position. However, when I attempt to zoom in with either a click or the scroll wheel, the image and axis both shrink and change position depending on where in the image I zoom in. I feel like the issue is due to the automatic updating of the CameraPosition and/or CameraTarget but I have played around with these settings, to no avail. 
I also feel like I could update the data aspect ratio by the zoom factor i.e. zoom = 2 => DataAspectRatio = [2 2 2], however I don't know how I can get the zoom factor while scrolling/clicking zoom!
All I want is to be able to zoom into the image without the axis changing its shape or position within the figure window. 
Thanks!
0 commentaires
Réponse acceptée
  Adam Danz
    
      
 le 10 Mar 2023
        
      Modifié(e) : Adam Danz
    
      
 le 10 Mar 2023
  
      Your intuitions are correct.  Panning and zooming reset the CameraPosition and CameraTarget back to default states which explain the change in axis view that happens after panning or zooming.  
One workaround is to control zoom by setting axis limits and/or camera viewing ange (camva).  
Another workaround that I haven't tested is to use the LimitsChangedFcn, a callback function in the axis rulers, to reset the camera position and target after pan/zoom interactions.  This function responds to changes to axis limits. However, this may have unintended consequences since these interactions may change the camera position and target so I'm not sure how you would update those camera properties in the callback function.    
5 commentaires
  Adam Danz
    
      
 le 10 Mar 2023
				I've had the same experience.  gcf works if, 
uifigure('HandleVisibility','on')
gcf()
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur Camera Views dans Help Center et File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


