Last active
February 3, 2026 20:27
-
-
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/29d65dad7ade9511c18087015f8e99a4088d72fa
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 : Playing time series with plotly through plotly-scala. | |
| // keywords : scala, chart, plotly, timeseries | |
| // publish : gist | |
| // authors : David Crosson | |
| // license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) | |
| // 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.4.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