Axes Tick Marks and Labels
Introduction
Getting tick marks to work correctly in Rave was hard.
Axis tick marks must be set in one of three ways:
- For normal numerical tick mark labels, you can use the normal MATLAB axes command x/y/ztick x/y/zticklabel properties.
- If the graph can (ever) display text variables such that the tick labels need to be text strings, call the function "ravemaketextticks" near the end of the ravecreateKEYWORD.m file. This function will create text object tick labels that smartly wrap/rotate. Non-text tick labels will use MATLAB's default way of making tick labels.
- If the graph needs custom tick labels (i.e. anything not covered by the first two bullets), call the function "ravemakecustomticks". Note that ravemaketextticks is essentially just a wrapper for ravemakecustomticks that automaticates the proper syntax. When you need more flexibility, use ravemakecustomticks.
Tick Label Sizing/Text Wrapping
Tick labels are drawn in the font and fontsize in raveprefs.fonts.graphname and raveprefs.fonts.graphsize. When these properties are changed via the setup tab (raveeditthemefontsgui), the function characterwidths is called. This function attempts to determine how many pixels each keyboard character will occupy on screen, and stores this info in raveprefs.fonts.graphwidth. (Non-keyboard ASCII characters are treated as 1 pixel. The characterwidths function could easily be modified to include other ASCII characters if needed.)
Tick label wrapping is really only an issue for the x-axis, since y-axis text is stacked vertically so the labels never interfere with each other. The function ravemovecustomticks is called by raveresizeaxes to move tick labels as a graph is moved/resized and to wrap text tick labels when necessary/possible. The function betterlinewrap determines if the ticklabel should be wrapped by comparing the available on-screen pixels (i.e. the distance between tick marks) to the estimated width of the ticklabel. If the width>available space, the string will be wrapped after a space or any of the characters +-/*})],_ or before the characters {([. If the string cannot be sufficiently wrapped (for example because it is one long word with no spaces or if even after wrapping it is still too wide) then ALL ticklabels for that axis will be rotated so the text reads vertically.