Skip to content

Instantly share code, notes, and snippets.

@satoshihirose
Created November 16, 2014 02:56
Show Gist options
  • Save satoshihirose/49fac5ad48b39c5970ae to your computer and use it in GitHub Desktop.
Save satoshihirose/49fac5ad48b39c5970ae to your computer and use it in GitHub Desktop.
breeze-viz-example
object Main {
def main(args: Array[String]) = {
import breeze.linalg._
import breeze.plot._
import breeze.numerics._
val f = Figure()
val p = f.subplot(0)
val x = linspace(-10.0,10.0)
p += plot(x, sin(x), '.')
p += plot(x, cos(x), '.')
p.title = "lines plotting"
val p2 = f.subplot(2,2,1)
val g2 = breeze.stats.distributions.Gaussian(0,1)
p2 += hist(g2.sample(100000),100)
p2.title = "A normal distribution"
val p3 = f.subplot(2,2,2)
val g3 = breeze.stats.distributions.Poisson(5)
p3 += hist(g3.sample(100000),100)
p3.title = "A poisson distribution"
val p4 = f.subplot(2,2,3)
p4 += image(DenseMatrix.rand(200,200))
p4.title = "A random distribution"
f.saveas("image.png")
}
}
@madeinquant
Copy link

try to execute the code in a docker "all-spark-notebook", however, it cannot be executed in jupyter notebook. An error was encountered. Please comment how to fix it, thank you.

Name: Compile Error
Message: <console>:21: error: object plot is not a member of package breeze
           import breeze.plot._
                         ^
<console>:24: error: not found: value Figure
           val f = Figure()
                   ^
StackTrace: 

@duxan
Copy link

duxan commented Sep 17, 2018

You should explicitly provide breeze-viz as dependency, for example for sbt: add libraryDependencies += "org.scalanlp" %% "breeze-viz" % "0.13.2" to build.sbt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment