# plt programming examples

The seven applications in the signal processing folder and the nine applications in the math folder discussed so far are all good demonstrations of the use of the plt plotting routine and many of its features. However, the focus on those applications is more about the signal processing and math topics than as a tool for learning how to use plt. Also, most of them are complex enough that it would be a challenging place to begin.
For that reason, this toolbox includes an additional set of 21 demo programs (located in the demo folder). These demo programs are intended to highlight just a few of the plt plotting features and are kept simple enough that they will be a good introduction to the plotting package.
At first, you probably won't know which of these 21 demo programs will be the most relevant to you. So if you have never used this toolbox before, the best starting point is to run demoplt.m which is also included in the demo folder. You can read more about it in the demoplt section, but really all you need to know is to start it by typing demoplt in the command window, and then clicking on the All Programs button.
The 21 demo programs (not counting demoplt.m) in the demo folder are described below in the order those programs appear in demoplt:

## CLICK on the thumbnails below to see the full-size image

### plt5.m
| This is a simple script that creates a plot containing 5 traces. Hopefully, you have already been running this script while following through the earlier sections. Note how the five y-vectors are combined to form a single plt argument. Note the use of the 'Xlim' and 'Ylim' arguments to control the initial axis limits. Note the use of 'LabelX' argument to assign a label for the x axis. Note the use of the 'LabelY' argument to add a label for both the left and right-hand axes. Note that plt will use a right-hand axis since two labels were included in the LabelY parameter. Usually the 'Right' parameter is included to specify which traces are to use the right axis, but in this example, the parameter was omitted, so plt defaults to putting just the last trace on the right-hand axis.

### plt50.m
| This script is an expansion of the simple plt5.m example to demonstrate additional features of plt. Note that two plots appear in this figure. There are two methods that you can use with plt to create figures containing multiple plots. The first is to use the subplot parameter to create multiple plots with a single call to plt. (This is demonstrated by the subplt.m, subplt8.m, subplt16.m, subplt20.m, pub0.m, pub2.m, pltmap.m, and weight.m programming examples). The second method (which is used here as well as in the pub3.m example) is to use a separate call to plt for each plot. The first plot (upper) is created by a call to plt that is quite similar to the one used in the simple plt5.m example. plt creates the figure window as usual and then creates the upper plot inside the new figure. Both a left and right hand axis are used for this plot. We are free to put as many traces as we want on either the left or right hand side, although in this example we put all the traces of this plot on the left hand axis except for the last one (trace Tr40) which is put on the right hand axis (and is also drawn with a thicker trace). The two major differences between this (first) call to plt and the plt call used in plt5.m are: The number of traces has been expanded from 5 to 40. Without additional action, this would create a TraceID box (legend) containing 40 trace names in a single column. However, this would not work well or look good to cram such a long list into the small space available. To solve that problem the the TIDcolumn parameter has been used to create a TraceID box with two columns. The 'TIDcolumn',20 included in the plt argument list actually specifies the number of items to put in the second column, which in this example means that both columns will contain 20 items. The 'xy' parameter is included to specify the location of the plot within the figure window. This wasn't needed before (in plt5.m) since the plot was automatically sized to fill the entire figure window. But now we want to create the plot in only a portion of the window to leave room for a second plot to be created. The object ID (-3) in the first row indicates that this position is to be used for both the left and right axis and also that all the cursor object positions should be positioned relative to these axes. (ID 0 also refers to both left & right axes but does not cause the other cursor objects to be repositioned as well). Although plt makes its best guess for the positions of the TraceID and Menu boxes often you will want to reposition them with the xy parameter to make best use of the available space. The 2nd row of the xy matrix repositions the TraceID box. The last row repositions the Yaxis label which otherwise would have been covered up by the TraceID box. Note that you don't need to figure out the numbers in the xy matrix since they will be reported to you as you adjust the positions of the screen objects with the mouse. (See the description of the xy parameter in the Axis properties section of the help file.) Following the first call to plt which displays the first 40 traces, a second call to plt is used to display the remaining 10 traces in a plot below the first one. As before we use the 'xy' parameter to get the plot to fit in the remaining open space of the figure. As with the first plot, we also include both the left and right hand axis. We were again free to put as many of these traces as desired on either side, but we choose to put only trace 5 on the right hand axis with all the remaining traces on the left axis. The most important difference between the first and second plt calls is that in the second call, we include the 'Fig',gcf in the parameter list. (gcf stands for "get current figure handle"). This tells plt not to open a new figure for the plot as usual, but rather to put the plot in the specified figure. The 'Fig' parameter must be either at the beginning or at the end of the plt parameter list. (All other plt parameters may be placed anywhere in the parameter list). You may notice that the xy parameter for this plot includes an imaginary component in the last element of the axis position. The reason for this is that the sizes of the cursor objects are relative to the plot size. This sometimes makes the cursor objects too small when the plot is a small fraction of the figure size. To fix this problem, one can enter a minimum width or height in the imaginary component of the width and/or height values. A few other features of the first (upper plot) are worth pointing out: With so many traces, the ability to use the legend (i.e. the TraceID box) to selectively enable or disable individual traces becomes even more compelling. Although the traces and the legend are color-coded, it's difficult to distinguish every trace based on color, so clicking on a legend item is often useful to uniquely identify a trace. The 'Pos' parameter is used to increase the figure area by about 30% from the default of 700x525 pixels to 830x550. This gives room to fit both plots into the figure area without overcrowding. The 'HelpFileR'' parameter is used to specify which help file will appear when you right-click on the Help tag in the menu box. Normally the file specified will contain help for the currently running script. In this case, prin.pdf is just used as an example and in fact, has nothing to do with plt50. The use of the 'closeReq' parameter is shown, although in this case, the function specified merely displays a message. Look at the afilt.m and wfall.m demos to see examples of a somewhat more sophisticated close request function. In situations like this with so many traces on the plot it can be difficult to find the cursor. The line following the first call to plt solves this problem by increasing the cursor size from 8 to 20 as well as by changing the cursor shape from a plus sign to an asterisk.

### pltn.m
| Similar to plt5 and plt50, except that this is a function instead of a script. This function takes an argument that specifies how many traces to plot. For instance pltn(1) will plot a single trace, and pltn(99) will plot 99 traces. If you specify more traces than this, the trace IDs are not displayed (since there will not be room for them). pltn with no arguments does the same thing as pltn(99). You can change the number of traces plotted even after pltn is already running by entering a new number in the "# of lines" edit box (under the TraceID box). Try entering "1000" into this edit box just to see that plt can handle such a large number of traces! Going much beyond 1000 traces is a good performance test, since on slower computers you will start to notice a significant lag in pan operations. The TIDcolumn parameter is used to divide the trace IDs into up to three columns if necessary. (Showing 99 trace IDs in one column wouldn't be practical.) TraceIDs are disabled when more than 99 traces are specified. (Otherwise, plt would give an error message.) Uses the 'Ystring' parameter to show a continuous readout of the cursor index Uses the 'Xstring' parameter to show a continuous readout of the date and time corresponding to the cursor X position. Note the edit box form is selected by placing a question mark character at the beginning of the string. A popup menu (pseudo object) is created below the x-axis label which allows you to adjust the line thickness. Notice that you can right-click on the popup to increment the line thickness (which sometimes is more convenient than opening the popup menu). A callback is written for the Xstring edit box that moves the cursor to the index with a corresponding time as close as possible to the entered value. For example, try this: Click on the top trace (which makes it easy to see the cursor). Enter dates into the edit box - e.g. "30 dec 2006", or "3-jan-07 9:59", etc. Verify that the cursor moves to the corresponding point.

### vbar.m
| This script demonstrates the use of Pvbar.m and Pebar.m to plot vertical bars and error bars respectively. Some things to note about vbar are: The first Pvbar in the argument list plots two functions on a single trace (green) with the 1st function (phase1) defining the position of the bottom of the vertical bars and the 2nd function (phase2) defining the position of the tops of the bars. The second Pvbar in the list plots 3 functions (called serp, bell1, and bell2). The 3 columns of the first Pvbar argument define the x coordinates for those three functions. The next argument (0) indicates that the bottom of all the vertical bars is at y=0. The last Pvbar argument gives the y coordinate for each of the 3 functions (one function per column). The next trace definition (the data argument pair after the 'linewidth') plots two traces corresponding to the two columns of poly23. The 1st column is a 2nd order polynomial and the 2nd column is 3rd order The next trace definition uses Pebar function to create two error bar traces, the first trace defined by the first column of each of the 3 arguments and the second trace defined by the second column. The 'Linewidth' argument appears in the middle of the plt call to change the width of only the traces defined earlier in the argument list. The 'TraceID' argument is used to assign names for each trace that are appropriate for the data being displayed. The 'xy' argument is used to widen the TraceID box to make room for the longer-than-usual trace ID names The '+FontSize', '+FontWeight', '+FontAngle', '+Xtick', '+Ytick', arguments are used to modify the main axis properties of the same name (without the plus). The Grid pseudo object is used to create an 8x3 table of character data. This table doesn't have anything to do with the plot (and indeed is just filled with random gibberish), but it was included just to demonstrate an unusual way to use this pseudo object.

### wrkspace.m
| To demonstrate the workspace plotter, this script creates several vectors in the workspace (including a structure containing two vector fields) and then starts the workspace plotter by calling plt with no arguments. Workspace plotting is described here

### movbar.m
| This function plots a series of 40 random bars and displays a horizontal threshold line which you can move by sliding the mouse along the vertical green line. As you move the threshold line, a string below the plot reports the number of bars that exceed the threshold. (This demonstrates the use of the plt xstring parameter.) These two buttons are created: Rand: Sets the bar heights to a new random data set. Walk: Clicking this once starts a random walk process of the bar heights. Clicking a second time halts this process. The Walk button user data holds the walk/halt status (1/0 respectively) demonstrating a simple way to start and stop a moving plot. Note that you can move the threshold or press the Rand button while it is walking. Also, if you click on one of the vertical purple bars, the horizontal threshold bar will then follow the upper end of that vertical bar. If movbar is called with an input argument, the value of the argument is ignored, but movbar will start as if the walk button has been hit. The walking is initiated using the funcStart function so that control returns to the command prompt even though movbar continues to update the plot.

### trigplt.m
| This example demonstrates: showing the line characteristics in the TraceID using the TraceMK parameter setting the cursor callback with the moveCB parameter setting axis, TraceID box, and MenuBox positions using the xy parameter setting trace characteristics with the Linewidth, Styles, and Markers parameters setting an initial cursor position enabling the multiCursor mode modifying the colors and fonts of the Trace IDs. The use of the slider pseudo object The use of the plt 'HelpText' parameter to display temporary help information at the top of the plot window. This help text disappears when any parameter is changed but can be re-enabled by clicking on the help button or by right-clicking on the help tag in the MenuBox. Shows how to use inf in the 'Pos' parameter to position the figure in the upper right corner of the screen. In this example an extra 48 pixels is allocated to the title bar so that the menu bar and one toolbar can be enabled without pushing the title bar off the top of the screen. The clipboard button captures the figure as a bitmap into the clipboard Using zeros(6) in the plt call to define 6 traces. The slider callback will overwrite these zeros with the actual data to be displayed. Note that nan(6) would also have worked equally as well for this purpose. Using the ^ButtonD parameter to allow the user to change the axis title color using the ColorPick pseudo object. (Simply click on the axis title.)

### subplt.m
| The 'SubPlot' argument is used to create 3 axes. plt puts a single trace on each axes except for the main (lower) axis which gets all the remaining traces. In this case, since there are 5 traces defined, the main axis has 3 traces. Note that the traces are assigned to the axes from the bottom up so that the last trace (serp) appears on the uppermost axis. The 'LabelY' argument defines the y-axis labels for all three axes, again from the bottom up. You can also define the y-axis label for the right hand main axis, by tacking it onto the end of the LabelY array (as done here). The 'Right',2 argument is used to specify that the 2nd trace of the main axis should be put on the right hand axis. If this argument was omitted, plt would still have known that a right hand axis was desired (because of the extra y-label in the LabelY array) however, it would have put trace 3 on the right hand axis. (By default, the last trace goes on the right axis). The LineWidth and LineStyle arguments define line characteristics for all 5 traces. The 'TraceMK' parameter enables the trace selection box to show the line characteristics and the 'xy' parameter widens the trace selection box to make room for this. Note that all three plots have their own cursor supporting almost all the cursor features. The exceptions are delta cursors, the xView slider, and the multi-cursor mode. These modes will still be active but they apply only the the main (lower) axis. Only a single x-axis edit box is needed since plt keeps the cursors of all three axes aligned. Also, note that if you zoom or pan any of the 3 plots, the other two plots will adjust their x-axis limits to agree. A brief description of this example is added to the screen using the 'HelpText' parameter. As you will see in the other demo programs, the help text is usually removed when you start using the program, but in this case, the help text is left in place since it doesn't interfere with the plot area or controls. (However you can toggle the help text on or off by right-clicking on the Help tag in the menu box.)

### subplt8.m
| This script shows a slight expansion of the ideas found in subplt.m by increasing the number of axes from 3 to 8. The axes are arranged in two columns which allow the use of two different x axes (one for each column). Note that the four axes on the left are synchronized with each other as well as the four on the right, although the left and right halves are independent of each other and have different x axis limits and units. There are 11 traces defined in the plt argument list but only 8 axes are specified. The extra 3 traces go to the main plot (lower left). This means that the first 4 traces are on the main plot and the remaining 7 traces are assigned to the other 7 subplots. Although the black background used in most of the example programs makes it easier to distinguish the trace colors, some people prefer a white background and this script shows how to do that by using the 'ColorDef' parameter to select Matlab's default color scheme. Matlab's default trace color order only includes six colors and this may not be long enough or ordered ideally for a particular graph. The ColorDef parameter may be used to set the trace colors as desired. If (as in this example) the ColorDef parameter is a color specification (3 columns of numbers between zero and one) this color spec is used instead of Matlab's current trace color order default. The first line of this script defines this color order using Matlab's traditional style. The 2nd line defines the same color sequence using an alternate style allowed by plt which you may also use if you find that more convenient than the traditional style. There's a special case (not used here) for the first entry in this color array. If it's [.99 .99 .99] (or 999999 in the alternate style) then the remaining colors are appended to the Matlab default color trace order. This may be convenient if for example you just want to add a few colors to the end of the list instead of merely replacing the whole color trace sequence. One advantage of the white background is that it is easier to publish a screen capture since the colors will not need to be inverted. When you click on this thumbnail, you will see a .svg file that was created from the menu bar's File SaveAs menu. (Enable the menu bar by clicking on "Menu" in the menu box). If this svg file was for publishing, we probably would have wanted to reduce the clutter of the figure by temporarily removing all the cursors and their associated controls and readouts. You do this by right-clicking on the y-axis label of the main plot - the one on the lower left. (I didn't do that for the svg file here so you could see all the screen elements.) After creating the svg file you can re-enable the cursors by right-clicking on the y-axis label again.

### subplt16.m
| This short script again is a slight complication from the previous example (supblt8). Not only do we double the number of axes but we take advantage of all the features of the subplot argument by varying the number of plots in each column as well as adjusting the vertical and horizontal spacings. Note that the whole number parts of the subplot argument specifies the plot widths and heights whereas the fractional parts specifies the horizontal and vertical spacing between the plots. So for example the "99.04" near the end of the subplot argument (for the rightmost plot) means that this plot should occupy 99% of the available height. The fractional part means that the space below the graph should be increased by 4 percent of the height of the available plotting area. Also remember that the negative numbers in the subplot argument are used to break up the plots into columns. So for example, the "-25.96" value tells plt that the first column should contain four plots (because it follows four positive numbers). The whole number part (25) means that the first column should use up 25% of the available plotting width. The fractional part (.96) means that we want to reduce the default spacing to the left of this column by 4% of the plotting width. (The default spacing results in a comfortable easy-on-the-eyes layout, but sometimes we want a tighter layout so we can have bigger plots.) For a more complete description of the subplot argument, refer to the Axis properties section as well as the GUI building with plt section of the help file. As in the previous example, the cursors for the various plots in each column are linked to each other but are not linked in any way to the cursors of the other columns. So for example if you move the cursor in the "tribell" plot (top of column 2) all the cursors of the four plots below it will also move so that they all point to the same x position. If you pan or zoom the x-axis of the tribell plot, the x-axis of the four plots below it will also be zoomed or panned so that the x limits remain the same for the entire column. This is what we call the subplot "linked" mode. The unlinked (or "independent") mode is demonstrated in the next example program (subplt20).

### subplt20.m
| The default subplot "linked" mode (demonstrated by the previous 3 subplot examples) makes sense when the columns share a common x-axis. However, in this example, the plots do not share a common axis, so the "independent" subplot mode is more appropriate. We tell plt to use the independent mode by putting an "i" after the first number of the subplot argument (Note the "32i" in the subplot argument of this example). The only thing now shared between the columns is space for displaying the cursor values. For example, the x and y edit boxes below the first column display the cursor values for the plot that you last clicked on in that column. The color of these edit boxes changes to match the color of the trace that you clicked on so you can tell at a glance which plot the cursor values refer to. One advantage of the independent mode is that we can fit more plots into a given space. We could probably display these 20 plots using the linked mode as well, but the figure window would have to be very large since in the linked mode a separate y-axis cursor edit box is included for every axis. As with the previous subplot examples, there are more traces than axes (21 traces and 20 axes). That means the first plot (lower left) gets 2 traces and a traceID box is added to allow you to select which one to display (or both). In this example all 21 traces contain the same number of points (301). However, this was just done for the convenience of the code generating the fake data to display. Each of the 21 traces could include a different number of points and the script would work equally as well. As you experiment with these plots, be aware of the concept of the "current cursor" (or "current plot" if you prefer) which is important since there are 16 different cursors visible. The current cursor is the cursor belonging to the last plot that you clicked on. When you click on one of the five menu box tags (LinX, LinY, Mark, Zout, XY<->) the appropriate menu box operation will only be applied to the current cursor. Likewise for the up/down arrow buttons (peak/valley finder) as well as the "circle" button which toggles whether markers are positioned over the trace data values. The only exception is the Delta button (delta cursor). This always operates on the main plot (lower left) regardless of which cursor is current.

### picplot.m
| This is the simplest example that demonstrates the use of the image pseudo object. A jpeg image (from the plt documentation section) is read in, converted to indexed color, and then plotted using plt and the image pseudo object. Running this program gives you a good opportunity to experiment with the cursoring, zooming, panning, and data editing techniques with image data. The input argument specifies the picture to display. For example: picplot C:\users\paul\Pictures\myFavorite.jpg If no input argument is given, the file glider.jpg is read from the plt\ini folder. The selected image file is displayed in color using the colorcube image map (see the thumbnail to the left). If you want to see the image in black & white (i.e. greyscale), check the gray checkbox below the plot. This will give you a greyscale image shown in the thumbnail to the right. (Remember you have to click on this thumbnail to see the complete image.)

### pltmap.m
| The purpose of this function is to demonstrate the use of the image pseudo object as well as to demonstrate 2D interpolation and 2D convolution. The subplot parameter is used to partition the figure into two parts. The left part displays a conventional 2D plot which includes the following five traces. A circle (red trace) whose radius is controlled by its amplitude slider (the leftmost slider above the plot in the "Y amplitudes" section). A hyperbola (orange trace). Its amplitude slider controls the asymptote slope. A polygon (yellow trace). Its amplitude slider controls both the size of the figure and the number of sides (which range from 3 to 7). A line (green trace). Its amplitude slider controls both the line's position and its orientation. The line is horizontal for slider values less than 5 and vertical otherwise. A line (blue trace). Its position and orientation are controlled by its slider in the same manner as trace 4. To better understand how the Y amplitude sliders affect the shapes, sizes, and positions of these 5 elements of the left hand plot, first stop the display from moving by clicking on the stop button. Then make adjustments to the five Y amplitude sliders while observing the changes in the left plot. One method used to create the image on the right axis is to use 2D convolution. This process is controlled by 3 controls to the left of the image (the kernel popup, the kernel size slider, and the kernel scale slider). This is what the kernel popup looks like once the popup is opened. First, we start with a completely black image by setting the z matrix to zero and choosing a modified version of the jet colormap which has had the first color element changed to [0 0 0]. Then we essentially make a copy of what's on the left axis onto the right axis image by changing one pixel of the image for each of the 500 markers on the left axis (100 markers for each of the 5 traces). The z values for these 500 points of the image are chosen using the appropriate index into the jet colormap so that their colors match the colors that appear on the left axis. (Direct scaling is used since otherwise the colors could not be made to match.) You can see what the image looks like after this first step by moving the kernel scaling slider down to its smallest setting. Next, the energy of these 500 points is spread out to affect the neighboring pixels (although the original 500 points are not changed). This is done by using one of these convolution kernels:
uniform |
1 | 1 | 1
1 | 1 | 1
1 | 1 | 1
| The uniform kernel is a commonly used "blur" effect where every kernel element is a one. So for example, this would be the kernel when the kernel size slider is set to 3.
conv11 |
1 | 4 | 6 | 4 | 1
4 | 16 | 24 | 16 | 4
6 | 24 | 36 | 24 | 6
4 | 16 | 24 | 16 | 4
1 | 4 | 6 | 4 | 1
| For a 1D smoother we can convolve the data with [1 1], sometimes called a [1 1] filter which can be represented as H(z) = 1 + z-1 (i.e. a single zero at z = -1). For more smoothing we could put two zeros at z = -1 which is the [1 2 1] filter (i.e. [1 1] convolved with [1 1]). Yet another zero at the same place gives us the [1 3 3 1] filter, and one more to yield [1 4 6 4 1] (the 4th row of Pascal's triangle if we start counting at 0). The moral equivalent of this for 2D filtering would be to start with [1] and then convolve with ones(2,2) five times (assuming the size slider is set to 5). This would yield the convolution kernel shown here. Notice that the 4th row of Pascal's triangle appears along each of the four edges.
pascal |
1 | 1 | 1 | 1 | 1
1 | 4 | 4 | 4 | 1
1 | 4 | 6 | 4 | 1
1 | 4 | 4 | 4 | 1
1 | 1 | 1 | 1 | 1
| Another way to extend the 1D [1 4 6 4 1] filter to 2 dimensions would be to place that row in both the center column and center row as well as along both diagonals.
reverse |
6 | 6 | 6 | 6 | 6
6 | 4 | 4 | 4 | 6
6 | 4 | 1 | 4 | 6
6 | 4 | 4 | 4 | 6
6 | 6 | 6 | 6 | 6
| This kernel is essentially the reverse of the previous one, with the largest values on the outside instead of the inside.
edge |
1 | 1 | 1 | 1 | 1
1 | 0 | 0 | 0 | 1
1 | 0 | 0 | 0 | 1
1 | 0 | 0 | 0 | 1
1 | 1 | 1 | 1 | 1
| This kernel has ones along all four edges and zeros elsewhere. This kernel and the previous one (reverse) have little to no practical applications and are included here just for the cool visual effects.
| All the kernels described above are scaled by an amount related to the scaling slider (the slider right below the slider that controls the kernel size). If you move the scaling slider to the bottom (minimum value) the effect of the convolution will be barely noticeable (or unnoticeable). As you move the scaling slider up the effects of the convolution become more noticeable and dramatic.
nearest | Even though this selection (as well as the following one) is in the kernel popup menu, it does not represent a convolution kernel. Instead, it refers to another method of creating the image known as nearest neighbor interpolation. The kernel size has no meaning here, but we use the kernel size slider to control one aspect of this interpolation. Let's start with the simpler case by setting the kernel size slider to its minimum value (1). The first step is similar to the first step for the convolution methods, i.e. 500 points are set that align with the same colors used for the 500 markers in the left hand plot. Again direct scaling is used for the image to allow these colors to match up. Next, each of the remaining points of the image is set to the color of the point that is nearest. So in the end, every point in the image is set to one of the 5 colors in use. This type of interpolation produces a continuous but steppy 3D surface (clearly not differentiable). Matlab's built-in griddata function can be used to perform this interpolation but to better expose the method, this interpolation is performed by the nearest function included inside pltmap.m. (This function consists of just a few lines of code.)
cubic | While the nearest neighbor interpolation results in an image with sharp color changes, the cubic interpolation produces a smooth (differentiable) 3D surface, so the colro changes are gradual. Start again with the kernel size slider set to 1 so the colors of the image match up with the colors of the markers of the left plot, again making it easier to see how the two plots are related. Next change the kernel size slider to any number bigger than 1. This causes several changes in the way the image is created. For one, instead of using fixed z values at the marker positions that relate to the color of the markers, the z value is taken from one of the five z value sliders (one slider for each of the 5 traces). Since these z values sliders move up and down randomly after the run button is clicked, a truly mesmerizing image is created with patterns that seem to never repeat. (Since all the Y and Z axis sliders are controlled by pseudo random sequences, the pattern will of course repeat eventually, but certainly not in your lifetime.) Secondly, the image scaling is changed from direct to scaled and also the z axis limits (clim) are adjusted to show only the 68% of the data in the middle of the range (i.e. μ ± &sigma). This results in a more vibrant display. With all these changes it is difficult to see how the image relates to the marker positions of the left plot, but you may be so hypnotized that you don't notice this. cubic is the default setting for this popup and so this will likely be the only mode seen by the casual user of the pltmap program.
Try exploring the features of pltmap by running through these tasks, both while the display is running and while it is stopped: Disable and enable the various traces by clicking on the trace names in the TraceID box. Note that the intensity map shape is determined only from the enabled traces. There is one exception to that rule that occurs when just a single line (trace 4 or 5) is enabled. In that situation, griddata won't have enough data to interpolate the image, so the data for trace 1 will also be used even if it has been disabled on the left hand plot. Select the nearest neighbor interpolation and enable the use of the Z amplitude sfliders by selecting a kernel size bigger than one. Then adjust the "Z amplitudes" for each of the 5 traces using the sliders and notice how these sliders change the image. (Only the right plot is affected.) You can also do this with the cubic interpolation. Click on the "color bar", the vertical color key strip near the upper left corner of the intensity map. Note that this cycles the color map through 11 choices (The 10 default color maps and one additional one called jetB added by pltmap. Often which color map to use is simply a visual preference, but for this program, the jetB color map is best so that the colors can match up between the left and right plots (at least when the Z amplitude sliders are not being used.) Note that the intensity map appears somewhat pixelated. This is because it is composed of a relatively small number of pixels (200x200). Try zooming in on an interesting-looking region of the intensity map using a zoom box. Hold the shift key down and drag the mouse to create the zoom box. Then click inside the zoom box to expand the display. Even though you still have only 200x200 pixels, the display will look smoother because all these pixels are focused on a smaller region of the more quickly changing z data. You can also zoom in by right-clicking on the "view all" button in the lower right corner. Then left-click on the view all button to expand the limits back to their original values to show the entire z data set. Also try opening a zoom box in the 2D plot (left). You can do this as before (shift key and mouse drag) or try the "double click and drag" mouse technique which avoids having to use the keyboard. You may be surprised to see that the intensity map zooms to show the region inside the zoom box of the 2D plot even as you are dragging the edge of the zoom box. If you then click inside the zoom box the 2D plot will also expand to show just the region inside the zoom box ... but let's not do this just yet. First, try moving the zoom box around. Do this by clicking the mouse near the mid-point of any edge, and dragging the zoom box around while holding the mouse button down. Also, note that if you drag one of the corners instead of a midpoint then the zoom box changes its size instead of its position. In both cases, the intensity map continues to update so that it shows only the zoom box region. These mouse motions are further described in the heading Adjusting the expansion box in the Zooming and panning section. Try sliding the resolution slider (just to the left of the color bar) all the way to the top of the slider. This will select a resolution of 800x800 (16 times as many pixels as before) so the display will look much smoother, but the drawback is that the update rate will be much slower. Try moving the slider all the way to the bottom (50x50 pixels). Now the intensity map will look very blocky, and the update rate will be very fast. Note that when you click inside the intensity map, the cursor will center itself on one of the blocks even if you click near the edge of one of the blocks. This makes it easier to interpret the Z value cursor readout (shown below the intensity map. Also, note the x and y cursor readouts are updated as you would expect every time you click on the image. Reset the resolution slider to 200 before continuing. The resolution slider works differently when 2D convolution is being used (i.e. when one of the first 5 choices in the kernel popup menu is selected.) In that case, the value from the slider is divided by 3 to determine the resolution. So for example, if the slider is set to 800, the resolution of the image is actually 267 by 267. This is done because high resolutions make it difficult to see what is happening with the 2D convolutions. Both plots are set in motion by clicking on the "Run" button. What happens is that a random selection of the 10 sliders above the 2D plot is selected to start moving. (The remaining sliders that are held fixed are made invisible so you can easily see what is changing). As the sliders are moving up and down, both the 2D and 3D plots are continuously updated to reflect the new information in the sliders. As this is happening you will see the small (blue) frame counter below the Run/Stop button counting down from 100 to zero. When zero is reached, a new random selection is made from the set of 10 sliders and the frame counter begins down counting anew from 100. While all this is happening, you may change the speed slider to adjust the motion rates and you also may adjust any of the other controls as well and observe the effects of these changes immediately. If you find that 100 frame count is too long or short for your taste, simply click on the yellow "100" and you will be presented with a popup menu allowing you to vary this frame count from as small as five to as large as 1000. Note that if you call pltmap with any argument, pltmap will start as if the run button has already been pressed. The funcStart function is used to initiate the run which allows pltmap to return control to the command prompt even while continuing to update the moving intensity maps.

### gui1.m
| Usually plt is used to build gui applications which include plotting, however this example doesn't include plots so that it remains trivial, making it a good example to start with if you have no previous exposure to Matlab GUI programming. The only pseudo object used in gui1 is the pseudo slider which is a collection of 5 uicontrols designed to work together to control a single parameter. The remaining controls used in gui1 are standard Matlab uicontrols. This GUI doesn't perform any useful function other than to demonstrate how to create various controls and move them around until the GUI appears as desired. The slider callback generates new random numbers for the listbox and textbox. The remaining callbacks are just stubs that notify you that you clicked on the object. You can most easily absorb the point of this example (as well as afilt.m) by reading this section of the help file: GUI building with plt.

### wfalltst.m
| This program demonstrates the use of pltwater, a general purpose 3D plotting utility which is described here in the Auxiliary plt functions section. A surface consisting of a sequence of sync functions is created in a 800 x 200 array (z) which is then passed to pltwater. We could have called pltwater with just a single argument (z) containing the data, but in this example we have included many additional parameters to tailor the display, including: nT skip x y all of which are described in the pltwater section of the help file as well as in the comments in pltwater.m. The remaining parameters included in the pltwater command in this example are not unique to pltwater, so they are passed directly to plt and are described in the main plt programming section of the help file. Those parameters include: HelpText TraceC CursorC Title ^Fontsize LabelY xy

### wfall.m
| This example has been largely superseded by the following example (wfalltst.m) which uses the general purpose pltwater 3D plotting routine. That's a far easier way to create a waterfall plot, although this example doesn't do that since it was written before pltwater was created. However, this example is still included since it may still be a good starting point if you want to develop a special purpose waterfall display that can't be created using pltwater. Demonstrates how to do hidden line removal which makes a waterfall plot much easier to interpret. Type wfall or wfall(0) to start wfall in its stopped state. (i.e. the display is not updating) Type wfall(1) or wfall('run') to start wfall with the display dynamically updating. The funcStart function is used to initiate the dynamic display updates which allows wfall to return to the command prompt while continuing to update the waterfall plot. One trace color (green) is used for all 30 traces ('TraceC' parameter) The 'TraceID' parameter is set to empty to disable the TraceID box. The figure user data is used to pass the handle structure (S) to the callback. Extensive use of the slider pseudo object to control the plotted data. The 'Linesmoothing' option is selected (which surprisingly speeds up the display dramatically on many systems) A pseudo popup in "super-button" mode is used to start and stop the display. The number of display updates per second is calculated every second with the results are shown in a large font below the plot.

### pub0.m
| All the plt examples discussed so far (above) use plotting formats appropriate for data exploration which is the main design goal for plt. However, plt can also use formats appropriate for creating plots for publication. This script demonstrates this by creating three different figures windows. Note that all three windows are created by calling pltpub() which calls plt with several parameters optimized for creating publishable plots. (pltpub.m is located in the main plt folder.) pub0 calls pltpub with the optional 'Cpick' parameter which disables all mouse-driven panning and zooming and also allows you to change the colors of most of the plot objects simply by clicking on them. Experiment by clicking on the various axes, labels, and lines in the 3 windows created by this program. If it is not obvious how to pick new colors from the ColorPick figure window, read about it in the Pseudo objects section. The first window (plot 1 - appearing near the top of the screen) is a bar chart that demonstrates how to embed the plot data inside the script as comments. It also demonstrates the use of the prin function to display a table of random numbers in a text box. The vertical position of the plot depends on the screen size. The second window (plot 2 - lower left portion of the screen) demonstrates how to distribute 15 functions among 5 subplots by using the 'SubTrace' parameter and how to set the trace colors and line styles. The third window (plot 3 - lower right) contains two traces with error bars, shows how to use the TraceID box as a legend. The special character ']' is used in the first TraceID to disable the shading of the trace name that is normally used to indicate the trace is on the right hand axis. Also the '+XtickLabel' parameter is used in the plt call to remove the tick labels on the x axis. Then an array of text objects are used to create specially formatted tick labels. The third window also demonstrates various ways of modifying the grid lines, and also shows the use of these prefixes: Prefix Object to modify + the left axis - the right axis < the left y-label > the right y-label . the x-label " TraceID text The three thumbnails to the left were created by shrinking screen captures of the three figure windows created by pub0.m. When you click on any of those thumbnails you will see a .svg image file that was created from the figure's file menu (Save As).

### pub1.m
| Shows the use of the pltpub command to produce publication-quality output and demonstrates some unusual graphics techniques such as multicolored lines and rotating text. The plot on the left side of the figure draws the solution to the following problem ... Divide a circle into n congruent parts so that at least one part does not touch the center. (Hint: as far as I know, the only solution uses n = 12) The plot on the right side of the figure draws several parametric curves including two Archimedean spirals (in red and blue) and the text is placed along a third Archimedian curve with the font size growing smaller as the text curve spirals inward. The small green curve in the middle of the spirals is known as a hypotrochoid. This thumbnail was created by shrinking a screen captures of the pub1.m figure window. When you click on this thumbnail you will see a .svg image file that was created from the figure's file menu (Save As).

### pub2.m
| In this example, a plt figure is created in its usual data exploration mode showing 6 traces of randomly generated data. Each trace contains over 50 thousand data points, although the display is zoomed to show only a small portion of the data. The 'xView' option is used to enable the xView slider which is particularly useful in situations like this where you are viewing only a small portion of a long data record. (The xView slider appears above the primary plot.) The idea is to use the xView slider or other cursor controls to pan and/or zoom the display to some area of interest and then press the "pub" button to generate a figure containing the selected data and optimized for publication. What makes this more interesting is that when you pan to a new section of the data and again press the "pub" button, the publication figure is redrawn using subplots to show both selected portions. In a like manner, successive presses of the pub button further subdivide the plotting area with each new data range appearing above the previous ones. To reset the pub figure so that only a single axis is plotted simply right-click on the pub button. The x axis of the data exploration window is plotted in units of days past a time reference (1-Jan-2013 in this example), but custom date ticks are used on the x axis of the publication plot. To reduce clutter, only the day and month are shown for all vertical grid lines except the last one (which includes day, month, & year). The TraceID box is typically placed to the left of the plot, although for the publication figure in this demo the TraceID box is placed right on top of the plot (more like a legend). This means that sometimes the TraceID box will obscure some of the data, but note that you can easily use the mouse to drag the legend around to a spot that does not interfere with the plot. This example may seem somewhat contrived - and indeed it was conceived mostly to demonstrate as many unusual plt parameters and programming techniques as possible.

### pub3.m
| In the previous three demos (pub0, pub1, pub2) we have seen how multiple plots can be created with a single call to plt (either in a single axis as in pub1, or in multiple axes by use of the subplot parameter). This demo also creates multiple plots in a single figure but it uses a separate call to plt for each plot. (This is allowed by using the 'Fig' parameter.) Some of the advantages of this method over using subplots are: Each plot may include a traceID box as well as a right hand axis. The position of the plots is completely general and doesn't demand fixed column widths as with subplots. (Note that the positions of the four plots in this example would have been difficult to create using subplots.) The cursor for each plot has the full generality and all the options of single plot graphs, unlike the restricted set of cursoring features provided by subplots. This advantage is not relevant for this particular example since cursors have been disabled by using the 'Nocursor' option. (Cursors were not needed since the goal of pub3 was to create an uncluttered publication quality result.) On the other hand, as the number of plots required on the figure increases, the restrictions of the subplots become an advantage because they allow a more compact plot spacing. You may also find the subplot method somewhat simpler to use, but these examples will allow you to compare these trade-offs. The traceID box is enabled for each plot in this example, primarily as a legend, but it can also be used to enable or disable any trace on the figure. Note that the 2nd trace of each plot (with traceID "samp") actually consists of 12 superimposed traces. (This is done by separating each of the 12 traces with a NaN element so that a line is not drawn from the end of each trace to the beginning of the next.) This could have been done by using a separate trace for each of the twelve "samp" traces, each with their own traceID, but that would have made the legend unnecessarily large and cumbersome. The blue trace is the average of the 12 superimposed traces and the red trace (markers only) is the standard deviation of those same 12 traces. The xy parameter contains the positions and sizes of each of the four plots. Note that a -3 is inserted in front of each of these positions. The -3 indicates that this position refers to both the left and right axes and also indicates that the traceID box (and the cursor controls if they were enabled) are to be positioned relative to the positions given for the left and right axes. This is described in the description of the xy parameter in the Axis properties section of the help file.

### xChart.m
| Data was collected in the t array measuring the performance of 13 different computational and graphics tasks, on an AMD Ryzen9 Windows system with 4 different Matlab versions. All these tasks are from the plt\demo folder except cbench (code specified in help text). Because plt runs in all versions of Matlab since 2001, these demo programs offer a good way to compare graphics performance between Matlab versions. To achieve more consistent results, Windows was rebooted before each version of Matlab was tested. The rows of the t array that represent time are inverted so that longer bars always represent better performance. Then each row of the "t" array is normalized so that the poorest performing version is given a value of one. I wouldn't normally overlay so much text over the plot, but in this instance I wanted the data to be self-explanatory. If you don't like the colors chosen for any of the text items, click on them and adjust the color with the ColorPick window. (This is possible because pltpub was called with the 'Cpick' argument.)