File Exchange

image thumbnail

trackball for better viewing 3D plot

version (9.6 KB) by simbaforrest
Better 3D plot viewing than Matlab's default rotate3d

1 Download

Updated 05 May 2016

View Version History

View License

Matlab's default rotate3d suffers from Gimbol-Lock effect. Using this trackball function, one can better enjoy 3D plot viewing.
axis equal;
grid on;
trackball on;

Cite As

simbaforrest (2021). trackball for better viewing 3D plot (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)


Hi Chen. I realized afterwards that the issue related to the axis units in the GUI rather than the code itself.


Hi Thomas,

I tried the script you provided and maximize the figure, it appears that the rotation works fine (unless the sphere is shown with a very small scale, and in that case, just zooming in should solve the problem). Let me know if this is the case.



Thanks for your response Chen. Actually it has nothing to do with data volume. Rotation is very smooth even with a one million cloud using pcshow() (Computer Vision Systems Toolbox) on my notebook. The issue appears to relate to the size of the figure window. Using the worked example:

axis equal;
trackball on;
axis vis3d;
axis off;

At the default figure window display size the function works nicely. However, if you maximize the figure, the mouse movements translate to very marginal rotations of the sphere. This is very frustrating when the current axis is in a GUI (which needs to be maximized). Is there a work around for scaling the mouse movements to a maximized figure. It would be a very useful function for GUI tools if this can be fixed.


Hi Thomas,

Are you drawing lots of points or lines? If that is the case, it will indeed be sluggish, which I think is due to Matlab's poor rendering pipeline rather than this script. Maybe you can turn on some hardware acceleration?



Do you know how to increase sensitivity of rotation to mouse movements? The code is an improvement over default rotate but is a little sluggish.

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: Virtual Tackball

Community Treasure Hunt

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

Start Hunting!