# A bit more on graphing under software control

Up a level : Nspire and Lua
Previous page : Nspire and 3D plotting before it was a part of the software
Next page : A favourite tool - the Locus

Have it under control

In the previous page, I used the spreadsheet to control the graphs, but one can do that under program control too.  As with the spreadsheet one needs to create a graph window, and some vectors of points. Then one makes scatter plots of the data and set all the desired properties of the plots in the graph window. One can then add points to the vectors, remove points and move points using programs.

Example code:

(Observe that the above code cannot be copy-pasted onto an Nspire document, it is just for show.  I had to change a few characters to make the list readable.-)

Running smiley(0,0) would (after setting the right colours, and so on) give us:

One can then move the figure around by calling smiley(x,y) for different values of x and y.  To make it a bit more interesting I added two sliders, one for x and one for y, and to make the call of the smiley function happen every time one has changed either x or y, I added a call to smiley(x,y) in a notebook window in the same document.

The document: smily.tns.

The above could have been done in easier ways, but this was done just to illustrate the principle.

A summary

• One can emulate plot commands using scatter plots
• One can make it event-driven by running calls to programs on a notebook page. Those programs will run every time one of the variables in the function call changes.
• One can also get a similar effect by using tables on a spreadsheet page. Changes in any variables used in the spreadsheet will cause the cells to be recalculated, and if the cells are used as coordinates for points in a graph, then the graph will update too.
• If one selects that the points in the graph are connected, one can still make several disjoint parts of the graph by separating the values in the tables by something that is not a number, e.g. “_”.