Code covered by the BSD License  

Highlights from
mplot: Multiple plots in a single figure with list box selection

5.0

5.0 | 1 rating Rate this file 9 Downloads (last 30 days) File Size: 5.16 KB File ID: #27111
image thumbnail

mplot: Multiple plots in a single figure with list box selection

by Levente Hunyadi

 

28 Mar 2010 (Updated 02 Oct 2010)

Adds multiple plot instructions to a figure and the user chooses which one to use from a list box.

| Watch this File

File Information
Description

mplot creates a figure with a list box and axes. The list box contains references to plot instructions to sketch data on the axes. Plot instructions are added to the list box with successive calls to the function mplot.

A plot instruction is either a function handle that takes at least a single argument, which is an axes handle; or a series of additional arguments passed to mplot, which are delegated unchanged to the built-in plot function.

When an item is selected in the list box, the corresponding instructions are used to plot data on the right-hand side axes. This means either calling the user-defined function with the axes handle as the first parameter, or the built-in plot function with all the additional arguments. When an item is double-clicked, a new figure window opens and data are plotted on a new pair of axes. This is useful when the axes are to be saved or exported.

EXAMPLES

mplot;
% creates an empty mplot figure if current figure is not already one

fig = mplot;
% returns the current figure handle in fig if it is an mplot figure, creating a new figure if needed

fig = mplot('new')
% unconditionally creates an empty mplot figure and returns its handle in fig

x = 1:100; y = rand(1,100); mplot(x, y, 'kx');
% adds a new plot to the currently active mplot figure; whenever the corresponding list item is clicked, plot(x,y,'kx') is executed

x = 1:100; y = rand(1,100); mplot(fig, x, y, 'kx');
% uses the specified mplot figure instead of the currently active one

x = 1:100; y = rand(1,100); mplot('my caption', x, y, 'kx');
% assigns the given caption to the newly added plot

fun = @(ax) plot(ax, x, y, 'k.'); mplot(fun);
% adds a new plot instruction given by a user function

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
uisplitter

MATLAB release MATLAB 7.6 (R2008a)
Other requirements If uisplitter is available in your .m file search path, the user can interactively adjust the relative size of the list box and the axes. See: http://www.mathworks.co.uk/matlabcentral/fileexchange/28841-uisplitter
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
24 Nov 2010 YT

This is quite a good tool for plotting multi-figure :-)

Please login to add a comment or rating.
Updates
02 Oct 2010

Added reference to uisplitter.

Tag Activity for this File
Tag Applied By Date/Time
gui Levente Hunyadi 29 Mar 2010 10:54:34
figure Levente Hunyadi 29 Mar 2010 10:54:34
plot Levente Hunyadi 29 Mar 2010 10:54:34
multiple Levente Hunyadi 29 Mar 2010 10:54:34
selection Levente Hunyadi 29 Mar 2010 10:54:34

Contact us at files@mathworks.com