Created
December 29, 2018 05:29
-
-
Save thomasnield/0f9cccd2cf2a58fecef8890f53845686 to your computer and use it in GitHub Desktop.
quick_distribution_scatterchart.kt
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
| import javafx.application.Application | |
| import javafx.scene.chart.NumberAxis | |
| import org.ojalgo.random.Normal | |
| import tornadofx.* | |
| fun main(args: Array<String>) { | |
| Application.launch(QuickScatterPlotApp::class.java) | |
| } | |
| class QuickScatterPlotApp: App(DistributionSampler::class) | |
| class DistributionSampler: View() { | |
| // Distribution Sampler goes here | |
| val distribution = Normal() | |
| val points = (0..100).asSequence() | |
| .map { distribution.get() } | |
| .map { it to distribution.getDistribution(it) } | |
| .toList() | |
| // ------------------------------- | |
| val minX = points.asSequence().map { it.first }.min()!!.toDouble() | |
| val maxX = points.asSequence().map { it.first }.max()!!.toDouble() | |
| val minY = points.asSequence().map { it.second }.min()!!.toDouble() | |
| val maxY = points.asSequence().map { it.second }.max()!!.toDouble() | |
| override val root = scatterchart("Quick Scatter Plot", NumberAxis(minX, maxX, 1.0), NumberAxis(minY, maxY, 1.0)) { | |
| series("") { | |
| points.forEach { | |
| data(it.first, it.second) | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment