Keypress Functions for Figures

KPFUN adds keypress functions to figures
1.6K Downloads
Updated 4 Oct 2006

View License

KPFUN adds keypress functionality to figures for those little things that one commonly forgets to do when making a plot in the first place. They are all things that are easy enough to do at the command prompt, but this function adds them at the touch of a key.

There are just under one hundred shortcut keys defined, so I won't describe them all here. This was written in release 6.5, so some of them are now not necessarily needed anymore (like panning, for example), but others are still very useful. Some of my favorites are:

* Rescale the colormap to fit the currently viewable area
* Invert axis/change axis styles
* Change line styles/markerstyles
* Steal data from a figure and save it in the base workspace
* Plot horizontal and vertical slices from image data
* Toggle grid
* Add/remove horizontal/vertical colorbars
* Manually modify pieces of the colormap
* Cycle or exchange the colormap
* Increase/descrease font sizes or line widths
* Cycle selected objects on the axes

Since there are so many shortcuts defined, I lose track of the ones I don't use, so this function also contains two aids: 1) The '/' key will result in a flashed message describing what the next key pressed does, and 2) The '?' brings up the KPFUN help info in a separate window. These two features are kind of useful on their own, particularly the internal 'flashmessage' function, which displays a message on the current axes for a short duration and then deletes it. It is an internal function here, but could be grabbed out and used on its own with very little effort.

Suggestions for improvements or additional features are welcome.

Cite As

Jeff Dunne (2024). Keypress Functions for Figures (https://www.mathworks.com/matlabcentral/fileexchange/12537-keypress-functions-for-figures), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Interactive Control and Callbacks in Help Center and MATLAB Answers

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