A Scala combinator-based plotting library.
The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:
EvilPlot is about combinators for graphics.
Documentation for EvilPlot is available here.
Add EvilPlot to your build with:
scala resolvers += Resolver.bintrayRepo("cibotech", "public") libraryDependencies += "com.cibo" %% "evilplot" % "0.6.3" // Use %%% instead of %% if you're using ScalaJSTake a look at the full getting started guide. EvilPlot is published for Scala 2.11 and Scala 2.12.
The low-level drawing API exists in the
com.cibo.evilplot.geometrypackage. Drawing primitives extend the
Drawabletrait. Once constructed, these can then be rendered using a
Graphics2DRenderContext, used for rendering to
Drawing primitives can be divided into three categories: drawing, positioning, and style. The following primitives for drawing are available:
The following primitives for positioning are available:
The following primitives for style are available:
com.cibo.evilplot.geometrypackage object provides several convenience functions for creating and composing these primitives.
For Interaction events
The plot API is in the
com.cibo.evilplot.plotpackage. Using this API, one creates a plot using a plot constructor. Once a plot is constructed, it is possible to change properties and add components to the plot. The following plot constructors are available (though additional constructors can be added):
Multiple plots can be combined using the following plot constructors: * Facets - Creates a 2-dimensional grid of plots with aligned axes. * Overlay - Stacks multiple plots on top of each other with aligned axes.
Plot components are available in the
com.cibo.evilplot.plot.componentspackage, though the
com.cibo.evilplot.plotpackage object provides implicits on the
Plotobject itself to make them easier to use.
Annotations are text (or other
Drawables) placed on top of the plot area. The X and Y coordinate parameters provide the relative position of the annotation (in the range 0 to 1).
The following methods (from the package object) are available for adjusting axes. These take arguments to alter the type of axis.
By default, the bounds of the plot area are determined by the data and plot constructor. However, it's possible to alter the bounds explicitly:
Labels for a single plot:
Labels for faceted plots:
Add padding around a plot area. This is mostly used for lining up plot areas of multiple plots in facets.
Custom plots can be constructed by creating new plot components, plot renderers, and/or plot element renderers.
A plot component is an object that goes around a plot area (such as a label or axis), in front of it (such as a trend line), or behind it (such as a background). Custom plot components can be implemented by extending
com.cibo.evilplot.plot.components.FacetedPlotComponentfor components that need to render differently for each facet).
To add a custom component to a plot (or any component), use either the
Plot, which will return an updated plot with the component.
plot :+ componentwill insert the component furthest away from the plot area and
component +: plotwill insert the component closest to the plot area.
Custom plot renderers are created by extending
com.cibo.evilplot.plot.renderers.PlotRenderer. Instances of these can then be used as an argument to
Plotto create custom plots.
A plot element is an instance of
com.cibo.evilplot.plot.renderers.PlotElementRenderer. These are used by
PlotRendererinstances to render elements of a plot. For example, the
PointRendererto render points. It is not necessary that a
PlotElementRenderers, but doing so allows them to share common code.
PlotElementRenderers are provided:
One-time setup: Install PhantomJS: On macOS, this is available from Homebrew:
brew install phantomjs
To run the demo:
bash $ sbt > compile > ~ fastOptJS
localhost:12345/index.htmlin your browser
Running the unit tests requires PhantomJS. Unit tests must be run from
sbt, not from within IntelliJ.