Multi-plot example – scatterplot matrix plots
In this section, we will learn how to have several plots in the same figure.
The key new method that allows multiple plots in the same figure is fig.subplot(nrows, ncols, plotIndex)
. This method, an overloaded version of the fig.subplot
method we have been using up to now, both sets the number of rows and columns in the figure and returns a specific subplot. It takes three arguments:
nrows
: The number of rows of subplots in the figurencols
: The number of columns of subplots in the figureplotIndex
: The index of the plot to return
Users familiar with MATLAB or matplotlib will note that the .subplot
method is identical to the eponymous methods in these frameworks. This might seem a little complex, so let's look at an example (you will find the code for this in BreezeDemo.scala
):
import breeze.plot._ def subplotExample { val data = HWData.load val fig = new Figure("Subplot example") // upper subplot: plot index '0' refers to the first plot...