Created
November 3, 2016 10:22
-
-
Save Sciss/cc39d6b7f12fe7245f123696dcc9c971 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trait Histo { | |
| def bins: Array[Int] | |
| def name: String | |
| } | |
| def mkChart(histo: Histo): XYChart = { | |
| val data = histo.bins.zipWithIndex.map { case (num, idx) => | |
| histo.center(idx) -> num | |
| } .toVector | |
| import scalax.chart.api._ | |
| val barWidth = histo.center(1) - histo.center(0) | |
| val fihData = data.toXYSeriesCollection(histo.name) | |
| val withWidth = new XYBarDataset(fihData, barWidth) | |
| val chart = XYBarChart(withWidth, title = s"Histogram for ${histo.name}") | |
| val plot = chart.plot | |
| plot.getRenderer.setSeriesPaint(0, Color.darkGray) | |
| chart | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment