Created
June 15, 2024 07:58
-
-
Save dacr/3fb70643c0a746f89f391a1e55ab7f2c to your computer and use it in GitHub Desktop.
declarative plotting with smile / published by https://github.com/dacr/code-examples-manager #057f5bda-281f-4ca6-8174-1b90321dce35/8691a7718b59dfedb39d175e4a1508ef422672be
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 : declarative plotting with smile | |
// keywords : smile, plotting | |
// publish : gist | |
// authors : smile documentation | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : 057f5bda-281f-4ca6-8174-1b90321dce35 | |
// created-on : 2024-06-11T16:49:54+02:00 | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
// --------------------- | |
//> using scala "3.4.2" | |
//> using dep "com.github.haifengl::smile-scala:3.1.1" | |
// --------------------- | |
import scala.math.* | |
import java.awt.Color.RED | |
import smile.plot.vega.* | |
import smile.plot.show | |
import smile.plot.Render.* | |
import smile.json.* | |
val bar = | |
VegaLite | |
.view() | |
.mark("bar") | |
.heightStep(17) | |
.x(field = "a", `type` = "ordinal", axis = JsObject("labelAngel" -> JsInt(0))) | |
.y(field = "b", `type` = "quantitative") | |
.data(jsan""" | |
[ | |
{"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43}, | |
{"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53}, | |
{"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52} | |
]""") | |
.description("A simple bar chart with embedded data.") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment