Last active
May 25, 2024 10:19
-
-
Save dacr/4d538f5d1c25f184cc918fd35a53987a to your computer and use it in GitHub Desktop.
first example with the breeze data visualization / published by https://github.com/dacr/code-examples-manager #397850d8-c2c7-44ae-a18b-3708ceba3704/d8c7fc5ca8e5743457ede5033c91a23792dd84db
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 : first example with the breeze data visualization | |
// keywords : plotting, breeze, math | |
// publish : gist | |
// authors : breeze documentation | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : 397850d8-c2c7-44ae-a18b-3708ceba3704 | |
// created-on : 2020-10-11T15:05:16Z | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
// --------------------- | |
//> using scala "3.4.2" | |
//> using dep "org.scalanlp::breeze:2.1.0" | |
//> using dep "org.scalanlp::breeze-viz:2.1.0" | |
// --------------------- | |
// breeze viz documentation : https://github.com/scalanlp/breeze/wiki/Quickstart | |
// Very interesting API :) | |
import breeze.linalg.* | |
import breeze.plot.* | |
import breeze.stats.distributions.* | |
import breeze.stats.distributions.Rand.VariableSeed.randBasis | |
val f = Figure() | |
val p = f.subplot(0) | |
val x = linspace(0.0, 10.0, 1000) | |
p += plot(x, x ^:^ 2.0, name = "a") | |
p += plot(x, x ^:^ 3.0, name = "b", style = '.') | |
p.xlabel = "x axis" | |
p.ylabel = "y axis" | |
p.legend = true | |
//f.saveas("lines.png") // save current figure as a .png, eps and pdf also supported | |
val p2 = f.subplot(2, 1, 1) | |
val g = breeze.stats.distributions.Gaussian(0, 1) | |
p2 += hist(g.sample(100000), 100) | |
p2.title = "A normal distribution" | |
f.saveas("subplots.png") | |
scala.io.StdIn.readLine("Press enter to quit") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment