Customizing plots
We now have a curve on our chart. Let's add a few more:
scala> val f2x = sigmoid(2.0*x) f2x: breeze.linalg.DenseVector[Double] = DenseVector(3.353501304664E-4... scala> val f10x = sigmoid(10.0*x) f10x: breeze.linalg.DenseVector[Double] = DenseVector(4.24835425529E-18... scala> plt += plot(x, f2x, name="S(2x)") breeze.plot.Plot = breeze.plot.Plot@63d6a0f8 scala> plt += plot(x, f10x, name="S(10x)") breeze.plot.Plot = breeze.plot.Plot@63d6a0f8 scala> fig.refresh()
Looking at the figure now, you should see all three curves in different colors. Notice that we named the data series as we added them to the plot, using the name=""
keyword argument. To view the names, we must set the legend
attribute:
scala> plt.legend = true
Our plot still leaves a lot to be desired. Let's start by restricting the range of the x axis to remove the bands of white space on either side of the plot:
scala> plt.xlim = (-4.0, 4.0) plt.xlim: (Double, Double) = (-4.0,4.0)
Now,...