Plotting is discussed in a separate chapter in this book. However, plotting is a very important part of any interactive computing system. Also ScalaLab is not a Scala library per se. It does own thing but uses Scala as a scripting language. As such, we will discuss ScalaLab's plotting here briefly. Hopefully, this will make explorative computing with ScalaLab much more interesting. Plus, ScalaLab supports a fairly extensive plotting API modeled after MATLAB. An example is shown in the following screenshot:
Let's see how to create a simple plot. We use the plot
method to plot a sinusoid as well as well as the title
method to set the title of the plot:
import scalaSci._ var x = linspace(0.0, 4.0 * PI, 100) var y = sin(x) plot(x, y)
You will get the plot given in the figure. Let's now explore slightly more advanced plots. For example, the plotting API allows subplots. That is, we can have several different plots in the same figure. For example, we might want to plot a signal...