AddReorderButtons

Add toolbar buttons to move plot objects forward and backward within axes.
889 Downloads
Updated 24 Jan 2008

No License

AddReorderButtons adds two buttons to the top toolbar of a specified figure. When clicked while a plot object is selected, they will move that object "forward" or "backward" in the rendering list. This is most practically useful for multiple 2D plots in the same axes, in which one plot may partially or completely obscure another; this is a simple way of moving the obscured plot forward without having to change the code that generated the figure.

I personally find this function most useful as part of my DefaultFigureCreateFcn callback, so that all new figures include the buttons. An example of how to do this is included in the download.

Written in R2007b, but should work for the most recent versions of MATLAB.

Example usage:
Enter the following commands at the MATLAB prompt:
>> figure
>> fv.vertices = [-1 0; 0 1; 1 0; 0 -1];
>> fv.faces = [1 2 3 4];
>> fv.facevertexcdata = [0 1 0];
>> patch(fv,'FaceColor','flat')
>> fv.vertices = [-1 -1;-1 1;1 1;1 -1]./sqrt(2);
>> fv.facevertexcdata = [1 0 0];
>> AddReorderButtons

You should have a plot with two overlapping squares, one red and one green. Select the "Edit Plot" tool, and click on the square on top. Press the "Move Current Plot Object Backward" tool to see the reorder buttons in action.

Cite As

Geoffrey Adams (2024). AddReorderButtons (https://www.mathworks.com/matlabcentral/fileexchange/18136-addreorderbuttons), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2007a
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

Added example usage to description.