Last active
February 3, 2026 20:26
-
-
Save dacr/43ae1aabe27b2e4e5f1cd75fe41ed5cb to your computer and use it in GitHub Desktop.
smile scatter swing visualization / published by https://github.com/dacr/code-examples-manager #5ddf60b5-e2d9-4740-9f32-11b8254f54e5/99d615f8ef550be8919960dd9ab94f8c46e1d6f9
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
| // summary : smile scatter swing visualization | |
| // keywords : smile, chart, visualization, scatter, swing | |
| // publish : gist | |
| // authors : David Crosson | |
| // license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) | |
| // id : 5ddf60b5-e2d9-4740-9f32-11b8254f54e5 | |
| // created-on : 2021-03-05T09:23:01Z | |
| // managed-by : https://github.com/dacr/code-examples-manager | |
| // run-with : scala-cli $file | |
| // --------------------- | |
| //> using scala "3.4.2" | |
| //> using dep "com.github.pathikrit::better-files:3.9.2" | |
| //> using dep "com.github.haifengl::smile-scala:3.1.1" | |
| //> using dep "org.bytedeco:javacpp-platform:1.5.10" | |
| //> using dep "org.bytedeco:javacpp:1.5.10,classifier=linux-x86_64" | |
| //> using dep "org.bytedeco:arpack-ng:3.9.1-1.5.10,classifier=linux-x86_64" | |
| //> using dep "org.bytedeco:openblas:0.3.26-1.5.10,classifier=linux-x86_64" | |
| //> using dep "org.slf4j:slf4j-nop:2.0.13" | |
| //> using dep "com.lihaoyi::requests:0.9.0" | |
| // --------------------- | |
| /* | |
| sudo apt-get install libopenblas-dev libopenblas-base | |
| */ | |
| import scala.language.postfixOps | |
| import better.files._ | |
| import smile.read | |
| import smile.util._ | |
| import smile.math._ | |
| import smile.math.MathEx._ | |
| import smile.math.distance._ | |
| import smile.data._ | |
| import smile.data.formula._ | |
| import smile.data.measure._ | |
| import smile.data.`type`._ | |
| import smile.regression._ | |
| import smile.stat.distribution._ | |
| import smile.io._ | |
| //import smile.plot.vega._ // FOR VEGA RENDERING | |
| import smile.plot.swing._ // FOR SWING RENDERING | |
| import smile.plot.show | |
| // examples coming from http://haifengl.github.io/visualization.html | |
| implicit val renderer:Canvas=>Unit = JWindow.apply | |
| // -------------------------------------------------------------------- | |
| val inputFileName = "iris.arff" | |
| val inputFile = inputFileName.toFile | |
| if (inputFile.notExists) { | |
| val url = "https://gist.githubusercontent.com/myui/143fa9d05bd6e7db0114/raw/500f178316b802f1cade6e3bf8dc814a96e84b1e/iris.arff" | |
| for {out <- inputFile.newOutputStream.autoClosed} {requests.get(url).writeBytesTo(out)} | |
| } | |
| // -------------------------------------------------------------------- | |
| val iris = read.arff("iris.arff") | |
| println(iris.summary()) | |
| // -------------------------------------------------------------------- | |
| { | |
| val canvas = plot(iris, "sepallength", "sepalwidth", "petallength", "class", '*') | |
| canvas.setAxisLabels("sepallength", "sepalwidth", "petallength") | |
| show(canvas) | |
| } | |
| // -------------------------------------------------------------------- | |
| { | |
| show(plot(iris, "sepallength", "petallength", "class", '*')) | |
| } | |
| // -------------------------------------------------------------------- | |
| println("enter to exit"); scala.io.StdIn.readLine() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment