More advanced scatter plots
Breeze-viz offers a
scatter
function that adds a significant degree of customization to scatter plots. In particular, we can use the size and color of the marker points to add additional dimensions of information to the plot.
The scatter
function takes, as its first two arguments, collections of x and y points. The third argument is a function mapping an integer i
to a Double
indicating the size of the ith point. The size of the point is measured in units of the x axis. If you have the sizes as a Scala collection or a Breeze vector, you can use that collection's apply
method as the function. Let's see how this works in practice.
As with the previous examples, we will use the REPL, but you can find a sample program in BreezeDemo.scala
:
scala> val fig = new Figure("Advanced scatter example") fig: breeze.plot.Figure = breeze.plot.Figure@220821bc scala> val plt = fig.subplot(0) plt: breeze.plot.Plot = breeze.plot.Plot@668f8ae0 scala>...