So far, we have just plotted lines using the default settings. Breeze lets us customize how lines are drawn, at least to some extent.
For this example, we will use the height-weight data discussed in Chapter 2, Manipulating Data with Breeze. We will use the Scala shell here for demonstrative purposes, but you will find a program in BreezeDemo.scala
that follows the example shell session.
The code examples for this chapter come with a module for loading the data, HWData.scala
, that loads the data from the CSVs:
scala> val data = HWData.load data: HWData = HWData [ 181 rows ] scala> data.heights breeze.linalg.DenseVector[Double] = DenseVector(182.0, ... scala> data.weights breeze.linalg.DenseVector[Double] = DenseVector(77.0, 58.0...
Let's create a scatter plot of the heights against the weights:
scala> val fig = Figure("height vs. weight") fig: breeze.plot.Figure = breeze.plot.Figure@743f2558 scala> val plt = fig.subplot(0) plt: breeze.plot.Plot ...