FixTicks - automatic redraw ticks on any axis

Version 1.0.0.0 (2.41 KB) by Jacco
Increase the number of ticks using intelligent spacing without having to manually specify them.
66 Downloads
Updated 11 Mar 2016

View License

FixTicks tries to automate creating a custom number (either minimum or exact) of ticks on any axis. A simple algorithm will try to automatically determine a reasonable spacing. Ticks will try to include the limits if they are nicely rounded and an even number of ticks will always include zero (if present).
Actions such as zooming and setting an axis limit can cause ticks to be lost and make plots look bad. Equally some plotting functions such as plotyy and using subplots cause a figure to have less ticks than usual. The usual proposed solution is to set the ticks manually (set(ga,'YTicks',linspace(lb,ub,5)), however this solution creates non-intelligent spacing unless you want to micromanage all your ticks. You want nice rounded ticks automatically! Simply invoke:

fixticks();

after you're done plotting and setting limits etcetera, and voilà your Y-axis ticks are again nice!

Trough arguments (all are optional) you can control the behaviour. By default it will draw 5 ticks at minimum on the Y-axis of the current graphic object. Full arguments are as follows: fixticks(h, ax, ticknum, strict), where h (=gca) is the handle to the desired graphic object (for instance when using plotyy!), ax (='Y') allows to specify the desired axis, ticknum (=5) set the minimum or exact number of ticks, for strict (=false) being set to false or true, respectively.

Cite As

Jacco (2024). FixTicks - automatic redraw ticks on any axis (https://www.mathworks.com/matlabcentral/fileexchange/55921-fixticks-automatic-redraw-ticks-on-any-axis), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2015b
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!
Version Published Release Notes
1.0.0.0

typos