demoplt




In the demo folder you will find 35 example programs to help you learn how to take advantage of many of plt's features. Also included in the demo folder is demoplt.m, a script which makes it easy to start any of the example programs by clicking on the appropriate button or to run all of them in sequence (in the order listed below) by clicking the "All Demos" button.
I strongly recommend running through the All Demos sequence at least once. Many of the questions emailed to me about plt are something like "can plt do xxxxx?", but if they had only clicked through the All Demos sequence once, most likely they would quickly discover that the answer to this question was "yes". Running demoplt is also a good way to verify that plt is working as properly on your system. Just type cd plt\demo  and then demoplt at the command prompt. The cd command is not necessary if you have added the plt\demo folder to the Matlab path - which is done automatically if you have installed plt as a toolbox. (Installing plt as a toolbox is possible with Matlab R2014b or later.)

plt5.m is first on the list because it is the simplest most basic example. The other demos appear in alphabetical order. As each demo is run, you may peruse the code for the demo program currently being run in the demoplt list box. Also the number of lines of code (not counting the comment lines) appears in the lower right corner of the figure to give you an idea of the complexity of each example. Use the list box scroll bars to view any portion of the code of interest. If the text is to big or small for comfort, adjust the fontsize using the fontsize popup menu in the lower right corner of the demoplt figure. This fontsize is saved (in demoplt.mat) along with the current figure colors and screen location so that the figure will look the same the next time demoplt is started. (Delete demoplt.mat to return to the original default conditions.) If you are running a very old version Matlab (older than 7.0) then the gui1 button is replaced by the gui1v6 button because gui1.m uses a uitable which is not supported in Matlab 6. (The uitable is replaced with a radio button in qui1v6).

Clicking on the small help button to the right of the All Demos button brings up the plt help file pointing to the Programming examples section (the section you are now reading). On Windows based system this is done using the windows 'hh.exe' utility to read the plt.chm help file. For other operating systems, the browser is used to open the relevant html help file.


When you click on the "All Demos" button, the first demo program appears (plt5.m) and the All Demos button changes to a continue button. In addition, this figure appears above the plt5 window to remind you that you need to keep pressing the continue button to see the remaining demo programs.
You can also use demoplt as a test suite to verify that plt is running properly with all the sample code without having to manually click the mouse to start each demo program. There are three ways of doing this:
  1. Type demoplt go at the command prompt. This will cycle quickly thru all the demo programs with no human interaction required. There are no pauses between each demo program and so this is useful for performance testing (as done in the xChart.m demo program). After the last demo program is run, demoplt is terminated and its figure window disappears.
  2. Type demoplt Go at the command prompt. Using the upper case "Go" has a similar result as with the lower case "go" except that a one second pause is added after each demo is executed so that you can verify that each figure has been rendered.
  3. You can start demoplt normally (i.e. with no arguments) and then instead of left clicking on the "All Demos" button as before, you can right click on that button. The result is the same as if you had typed demoplt go (i.e. there are now pauses between each demo) except that demoplt is not terminated after the last demo program is run.
For all three of those methods, the elapsed time required to execute all the demo programs is displayed in the command window after the last demo program is run. The elapsed time shown after demoplt Go will be about 35 seconds more than the other methods because of the one second after each demo is executed.

In addition to its main role as a demo program launcher, demoplt demonstrates the use the ColorPick pseudo object. (A pseudo object is a collection of more primitive Matlab objects, assembled together to perform a common objective.) The ColorPick pseudo object is useful whenever you want to allow the user to have control over the color of one of the graphic elements. In demoplt there are 4 such elements: The text color, the text background color, the button color, and the figure background color. The ColorPick window is activated when you click on any of the three small color squares (frames) or if you right-click on the figure background edit box. When the ColorPick window appears you can use the sliders or the color patches to change the color of the respective graphic element. For more details, see the Pseudo objects section in the help file.

An optional feature of the ColorPick object is the color change callback function - a function that's called whenever a new color is selected. This feature is demonstrated here by reporting all color changes at the top of the listbox (i.e. before the example code listing).

Although it's unrelated to plt, demoplt also demonstrates the use of the close request function, which in this example is assigned to demoplt('close') and gets called when you close the demoplt figure window. If you have changed the figure size, the fontsize popup, or any color selection this close request function brings up a modal dialog box consisting of these three buttons: