File Exchange

image thumbnail

ThreeVector

version 1.0.0.0 (33.4 KB) by Daniel J O'Shea
Draws three-pronged labeled axis vectors that indicate 3d plot rotation

1 Download

Updated 28 Mar 2014

View License

This class draws three vectors in the lower, left corner of an axis which indicate the orientation of the x, y, and z axes using a three pronged symbol. The ends of the vectors are labeled according to the axis xlabel, ylabel, zlabel. It installs callback methods to update these axes vectors when the plot is zoomed, rotated, panned, or resized. It also updates the vector labels when xlabel, ylabel, zlabel are set, or xlim, ylim, or zlim are changed. ThreeVector also deals gracefully with figure save and load by appropriately finding and updating internal graphics objects handles on load.
Usage:

tv = ThreeVector()
install for current axis

tv = ThreeVector(axh)
install for specific axis. if already installed,
returns the handle to the previously installed instance after
calling update()

tv.update()
force an update on the axis associated with tv

ThreeVector.updateFigure(figh [== gcf])
update all axes with ThreeVector installed within figure figh.

ThreeVector.updateAxes(axh [== gca])
update axis axh if ThreeVector installed

ThreeVector.demo()
plot a demo surface and install ThreeVector

Properties: setting these will automatically result in an update()

fontSize : font size used for axis labels, defaults to get(axh, 'FontSize')

fontColor : 3 x 1 color vector or plot-color-string (e.g. 'k')
used to label axes, defaults to 0.1 gray

lineWidth : line width used for axis vectors

lineColor : 3 x 1 color vector or plot-color-string (e.g. 'k') for
axis vector lines, defaults to 0.4 gray

vectorLength : scalar length of all axis vectors in cm

textVectorNormalizedPosition : position of axis labels along vectors
in units normalized to the vector length. E.g. 1 is end of vector,
0.5 is halfway along vector, 1.5 is 1.5 times the length of the vector.

axisInset: 2 x 1 vector of offsets in cm from bottom left corner.
in the form [offsetFromLeft, offsetFromBottom]

Author: Dan O'Shea, {my first name} AT djoshea.com (c) 2014

NOTE: This class graciously utilizes code from the following authors:

MinLong Kwong: For computing the data to figure space coordinate transformation matrix.
http://www.mathworks.com/matlabcentral/fileexchange/43896

Malcolm Lidierth: For the isMultipleCall utility to prevent callback re-entrancy
http://undocumentedmatlab.com/blog/controlling-callback-re-entrancy/

Cite As

Daniel J O'Shea (2021). ThreeVector (https://www.mathworks.com/matlabcentral/fileexchange/46062-threevector), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)

Shawn Mikula

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

Community Treasure Hunt

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

Start Hunting!