Saturday, April 16, 2016

Ploting simple plots by using GNUPlot and Scala

Does Scala have any frontend library to plot? ScalaPlot.

This article will demo how to plot a simple scatter chart.

1. Dependencies.

1.1 Install gnuplot.
>brew install pdflib-lite gnuplot

1.2 Download ScalaPlot.jar from here.

2. A simple scatter chart.

2.1 sbt config.
>libraryDependencies += "org.sameersingh.scalaplot" % "scalaplot" % "0.1"

2.2 SimpleApp code.
import org.sameersingh.scalaplot.Implicits._

val x = 0.0 until 2.0 * math.Pi by 0.1
output(PNG("/tmp/", "test"), xyChart(x ->(math.sin(_), math.cos(_))))

2.3 run.
scala -classpath "target/scala-2.11/simple-project_2.11-1.0.jar:scalaplot-0.1.jar" SimpleApp

Then, you will get result test.png:

1 comment:

  1. https://github.com/quantifind/wisp is also good scala plotting tool.

    ReplyDelete