-
Notifications
You must be signed in to change notification settings - Fork 8
Visualize
adampingel edited this page Jan 2, 2013
·
24 revisions
This package is part of the Axle domain specific language.
The show
function is available in the axle.visualize._
package.
It can be applied to several types of Axle objects.
That package also contains functions for creating files from the images: png
, jpeg
, gif
, bmp
.
For example:
show(plot)
png(plot, "plot.png")
axle.visualize.Plot
import util.Random
import collection._
import math.{ Pi, cos, sin }
import axle.visualize._
import axle.visualize.Plottable._
import org.joda.time.DateTime
val now = new DateTime()
def randomTimeSeries(i: Int) = {
val (phase, amp, f) = (Random.nextDouble, Random.nextDouble, Random.nextDouble)
("series %d %1.2f %1.2f %1.2f".format(i, phase, amp, f),
new immutable.TreeMap[DateTime, Double]() ++
(0 to 100).map(j => (now.plusMinutes(2 * j) -> amp * sin(phase + (j / (10 * f))))).toMap)
}
val plot = new Plot((0 until 20).map(i => randomTimeSeries(i)).toList, true,
title = Some("Random Waves"), xAxis = 0.0, xAxisLabel = Some("time (t)"),
yAxis = now, yAxisLabel = Some("a * sin(p + t/10f)"))
show(plot)
import axle.visualize._
import collection._
val fruits = Vector("apple", "banana", "coconut")
val years = Vector(2011, 2012)
val sales = Map(
("apple", 2011) -> 43.0,
("apple", 2012) -> 83.8,
("banana", 2011) -> 11.3,
("banana", 2012) -> 77.9,
("coconut", 2011) -> 88.0,
("coconut", 2012) -> 10.1
)
val chart = BarChart(
fruits,
years,
(fruit: String, year: Int) => sales((fruit, year)),
xAxis = 0.0,
title = Some("fruit sales")
)
show(chart)
TODO: show example of 2-feature KMeans clustering
TODO: show directed and undirected graph visualizations