Last active
May 8, 2023 20:34
-
-
Save dacr/3a59b0d98ef6e36dd70267cac3d29b59 to your computer and use it in GitHub Desktop.
Playing time series with plotly through plotly-scala. / published by https://github.com/dacr/code-examples-manager #450b643c-1a87-46b7-922b-3753e90b6c8f/c395e237436ca1a9e7a6b67f283af5fa018b0416
This file contains 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 : Playing time series with plotly through plotly-scala. | |
// keywords : scala, chart, plotly, timeseries | |
// publish : gist | |
// authors : David Crosson | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : 450b643c-1a87-46b7-922b-3753e90b6c8f | |
// created-on : 2020-05-31T19:54:52Z | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
// --------------------- | |
//> using scala "3.2.2" | |
//> using dep "org.plotly-scala:plotly-render_2.13:0.8.4" | |
// --------------------- | |
// -- https://github.com/alexarchambault/plotly-scala | |
import plotly._, element._, layout._, Plotly._ | |
val rand = new java.util.Random() | |
val xs1 = (0 until 500) | |
val ys1 = xs1.map { i => i + 60.0 * rand.nextDouble() } | |
val xs2 = (0 until 500) | |
val ys2 = xs2.map { i => 500 - i + 60.0 * rand.nextDouble() } | |
val data = Seq( | |
Scatter(xs1, ys1).withName("trendAA"), | |
Scatter(xs2, ys2).withName("trendBB"), | |
).map(_.withFill(Fill.ToNextY).withStackgroup("A")) | |
val myLayout = | |
Layout() | |
.withTitle("MyTimeSeries") | |
plot("plot.html", data, myLayout) | |
println("It should even open the default browser with that chart !") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment