org.nspl
nspl is a Scala library to describe and render scientific plots.
Entry points into the API:
- org.nspl.xyplot is the most important method to define a plot in Cartesian coordinate systems,
- org.nspl.data.DataSource. All data must be supplied as a DataSource. Its main abstraction is an iterator over rows (org.nspl.data.Row) where a row is an indexed sequence of doubles. Each row has the same length in a DataSource. A DataSource may be lazy (e.g. load data from disk on demand).
- org.nspl.par.apply describe settings governing most plots (axis labels, plot titles, ticks, etc),
- org.nspl.awtrenderer for methods to render the plot with Java AWT into PNG, JPG, PDF or a Java Graphics2D context,
- org.nspl.canvasrenderer for methods to render the plot with Html5 Canvas in the browser.
Premade plot factories for various types of plots:
- org.nspl.xyplot
- org.nspl.xyzplot Experimental 3D plot of a points and line segments mesh
- org.nspl.boxplot
- org.nspl.rasterplot Draws data as a bitmap / raster.
Data renderers:
- org.nspl.point for scatter plots
- org.nspl.line for line plots
- org.nspl.lineSegment for line or graph plots
- org.nspl.bar for bar plots
- org.nspl.area
- org.nspl.boxwhisker for box plots
- org.nspl.polynom
Data sources:
- org.nspl.data.DataTable Generic tabular data source on a row major double array
- There exist implicit conversion methods to provide DataSource views on
tuples of Doubles or other types from the standard library. Most of
these are not copying. They are imported with
import org.nspl._
import. - org.nspl.data.DataMatrix Data is viewed as a bitmap/raster: first dimension is x, second is y coordinates, third is color value
- org.nspl.saddle provides interface from Saddle types.
The more general scene graph and layout functionality of the library is exposed via:
- org.nspl.ShapeElem to describe a shape,
- org.nspl.TextBox to describe a text box,
- the
sequence()
method groups multiple elements in a sequence together e.g.sequence(List(elem1,elem2),VerticalStack)
, - the
group
methods group multiple elements together e.g.group(elem1,elem2,VerticalStack)
, one for each arity - Implementations of the org.nspl.Layout trait e.g. org.nspl.TableLayout
- Alignment helpers in org.nspl.Align
- Subclasses of org.nspl.Shape eg. org.nspl.Rectangle , org.nspl.Ellipse, org.nspl.SimplePath, org.nspl.Path
- org.nspl.fitToBounds, org.nspl.fitToWidth, org.nspl.fitToHeight methods
Rendering contexts:
- org.nspl.canvasrenderer for Html5 Canvas. This context is interactive with support for panning and zooming. See org.nspl.canvasrenderer.render
- org.nspl.awtrenderer for various format on the JVM. e.g see methods
like
org.nspl.awtrenderer.pdfToFile
- org.nspl.scalatagrenderer for SVG plots (Scala.js and JVM). See org.nspl.scalatagrenderer.renderToScalaTag
Type members
Classlikes
2D Affine Transformation Matrix in row major order
2D Affine Transformation Matrix in row major order
- Companion:
- object
- Companion:
- object
A rectangle for bounding boxes
A rectangle for bounding boxes
- Value parameters:
- anchor
an optional point termed the anchor. Certain layouts align to the anchor rather than to the edges of the bounding box
A Layout which puts elements into columns.
A Layout which puts elements into columns.
A Renderable element for data sources
A Renderable element for data sources
Unlike most other Renderable's DataElem is a placeholder in the scene graph. nspl does not insert the individual data rows into the scene graph but represent them with a DataElem. The data source will be enumerated at the time when the rendering context renders the DataElem.
- Companion:
- object
- Companion:
- object
A DataRenderer can render a datum a a side effect
A DataRenderer can render a datum a a side effect
DataRenderers describe the visual representations of single data rows. DataRenderers operate in a side effect with the provided context specific shape and textbox renderer.
It is guaranteed that the render method is called in a loop on all rows of a data source, after which the clear method is called exactly once.
Data renderers interpret the data rows as it is applicable for their function e.g. the point renderer takes 2 numbers for the x, y coordinates and potentially numbers for the color value, and the top and bottom error bars. In contrast the box and whiskes renderer takes 5 numbers for the min/max/median/mean and the horizontal coordinate. If the data row is too short for the given data renderer then an error is thrown.
A Renderable of an Either of Renderables
A Renderable of an Either of Renderables
- Companion:
- object
A Renderable of a sequence of Renderables
A Renderable of a sequence of Renderables
- Companion:
- object
A Renderable of a sequence of Eithers of Renderables
A Renderable of a sequence of Eithers of Renderables
- Companion:
- object
A Renderable of a sequence of Options of Renderables
A Renderable of a sequence of Options of Renderables
- Companion:
- object
Describes the name and size of the font set used to draw letters
Describes the name and size of the font set used to draw letters
This description is independent of the rendering context. Each rendering context has to provide a GlyphMeasurer to compute the concrete space occupied by the given Font (font name and font size)
- Companion:
- object
A Font paired with a GlyphMeasurer forms a FontConfiguration
A Font paired with a GlyphMeasurer forms a FontConfiguration
A Layout which stacks elements beside each other and aligns the vertical axis.
A Layout which stacks elements beside each other and aligns the vertical axis.
Semantic information about parts of a plot
Semantic information about parts of a plot
Layouts tranform the bounding box of their members.
Layouts tranform the bounding box of their members.
Describes a line segment with the two end points
Describes a line segment with the two end points
Holds settings and parameters applicable for a different plots.
Holds settings and parameters applicable for a different plots.
See org.nspl.par
A shape built up by a path
A shape built up by a path
A path is a sequence of of path operations:
- move to point
- line to point (from last point)
- quadratic to (from last point)
- cubic to (from last point)
Final rendered bounds (if available) and identifier of a plot area
Final rendered bounds (if available) and identifier of a plot area
A raw reference used for reference based equality tests
A raw reference used for reference based equality tests
Used to identify certain parts of a composit plot
Relative font size
Relative font size
A relative font size of 1 represents the horizontal space taken by one letter
A Renderer provides a way to render a type into a RenderingContext
A Renderer provides a way to render a type into a RenderingContext
Concrete RenderingContext implementations need a Shape and TextBox renderer.
Abstract rendering context
Abstract rendering context
Provides methods to manipulate a state machine of transformation states
A Renderable describing a shape
A Renderable describing a shape
Path without curves. Points are joined by line segments.
Path without curves. Points are joined by line segments.
Font independent Stroke
Font independent Stroke
Width and dash are expressed in terms of doubles
Font dependent Stroke
Font dependent Stroke
Width and dash are expressed in terms of a relative font size
A Layout which puts elements into rows.
A Layout which puts elements into rows.
A Renderable describing a text box
A Renderable describing a text box
See the apply factory method in its companion object on how to construct one
- Companion:
- object
Holds a text layout
Holds a text layout
- Value parameters:
- bounds
outer bounding box of the layout
- lines
a sequence of lines. Each line is a string with the characters of the line and an AffineTransformation with the line's displacement.
- Companion:
- object
A Layout which stacks elements on top of each other and aligns the horizontal axis.
A Layout which stacks elements on top of each other and aligns the horizontal axis.
Inherited classlikes
A drag event over a plot area.
A drag event over a plot area.
- Value parameters:
- plotArea
identifies which plot area is being dragged. The bounds member of the identifier must be defined.
- Inherited from:
- Events
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
- Inherited from:
- Tuples1
An event born fro user interaction
An event born fro user interaction
- Inherited from:
- Events
Represents a plot legend drawn with a line
Represents a plot legend drawn with a line
- Inherited from:
- Plots
Represents a plot legend drawn with a point (circle)
Represents a plot legend drawn with a point (circle)
- Inherited from:
- Plots
A scroll event over a plot area.
A scroll event over a plot area.
- Value parameters:
- plotArea
identifies which plot area is being scrolled. The bounds member of the identifier must be defined.
- Inherited from:
- Events
- Inherited from:
- Plots
- Inherited from:
- Plots3D
Types
Inherited types
- Inherited from:
- Plots
Value members
Concrete methods
Resizes member to fit into bounds. Keeps aspect ratio.
Resizes member to fit into bounds. Keeps aspect ratio.
Resizes member to fit into height. Keeps aspect ratio.
Resizes member to fit into height. Keeps aspect ratio.
Turns a Seq of Renderables into a Renderable where the elements are laid out according to the given layout
Turns a Seq of Renderables into a Renderable where the elements are laid out according to the given layout
Turns a Seq of Renderables into a Renderable while the layout is not changed
Turns a Seq of Renderables into a Renderable while the layout is not changed
Turns a Seq of Renderables into a Renderable while the layout is not changed
Turns a Seq of Renderables into a Renderable while the layout is not changed
Turns a Seq of Renderables into a Renderable while the layout is not changed
Turns a Seq of Renderables into a Renderable while the layout is not changed
Turns a Seq of Eithers of Renderables into a Renderable while the layout is not changed
Turns a Seq of Eithers of Renderables into a Renderable while the layout is not changed
Inherited methods
A renderer which renders a data row a single parameterized line (y=a+b*x)
A renderer which renders a data row a single parameterized line (y=a+b*x)
- Inherited from:
- Renderers
Paints the area between the (x,y) and (x,0) or between (x,y) and (x,y2) if y2 is present
Paints the area between the (x,y) and (x,0) or between (x,y) and (x,y2) if y2 is present
- Inherited from:
- Renderers
A renderer which renders a data row as a horizontal or vertical bar
A renderer which renders a data row as a horizontal or vertical bar
- Inherited from:
- Renderers
- Inherited from:
- SimplePlots
- Inherited from:
- SimplePlots
- Inherited from:
- DataAdaptors
- Inherited from:
- DataAdaptors
- Inherited from:
- SimplePlots
- Inherited from:
- SimplePlots
A renderer which renders a data row as a box and whiskers plot
A renderer which renders a data row as a box and whiskers plot
The minimum, maximum, median and mean are rendered.
- Inherited from:
- Renderers
- Inherited from:
- SimplePlots
Need to iterate twice on the data: once for the bounds to get the axis right, once for the plot
Need to iterate twice on the data: once for the bounds to get the axis right, once for the plot
- Inherited from:
- DataAdaptors
- Inherited from:
- DataAdaptors
- Inherited from:
- DataAdaptors
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
Helper method to create a scene graph for a heat map legend
Helper method to create a scene graph for a heat map legend
A heat map legend is a band with different color values to help read off a color scale
- Inherited from:
- Plots
- Inherited from:
- DataAdaptors
- Inherited from:
- DataAdaptors
- Inherited from:
- DataAdaptors
Helper method to create a scene graph for a plot legend
Helper method to create a scene graph for a plot legend
A plot legend is a small table with text label and some visual representation which matches the visual representatin in the plot area
- Inherited from:
- Plots
A renderer which renders a data row as a sequence of joined line segments
A renderer which renders a data row as a sequence of joined line segments
Each data row is connected with a line segment in the order they are supplied in the data source
- Inherited from:
- Renderers
A renderer which renders a data row as series of potentially disconnected line segments
A renderer which renders a data row as series of potentially disconnected line segments
Each data row must provide both endpoints of the line segment
- Inherited from:
- Renderers
- Inherited from:
- Renderers3D
- Inherited from:
- DataAdaptors
A renderer which renders a data row as a point on a scatter plot
A renderer which renders a data row as a point on a scatter plot
- Inherited from:
- Renderers
- Inherited from:
- Renderers3D
A renderer which renders a data row as a polynom
A renderer which renders a data row as a polynom
It numerically evaluates the polynom sum(a_i x^i) and draws the resulting curve
- Inherited from:
- Renderers
- Inherited from:
- SimplePlots
- Inherited from:
- SimplePlots
Factory method to create the scene graph of a plot in a Cartesian coordinate system.
Factory method to create the scene graph of a plot in a Cartesian coordinate system.
Example a plot of a scatter plot of dots connected with lines:
val someData =
0 until 10 map (i => (i.toDouble, (i * i).toDouble))
val plot = xyplot((someData, List(point(),line()),InLegend("some"))(
par(
main="Main label",
xlab="x axis label",
ylab="y axis label"
)
)
- Value parameters:
- data
Triplets of data source, data renderers, legend configuration. Each triplet describes what data (DataSource) to be drawn and how to represent them (by the DataRenderers), and whether to include them in the legend. A single data source may have multiple visual representations e.g. a point and a line.
- parameters
Generic characteristics of the plot. see org.nspl.par.apply.
- Inherited from:
- SimplePlots
Helper method to create a scene graph for a plot area
Helper method to create a scene graph for a plot area
The plot area is the complete area of a single 2D plot :
- x and y axes (Cartesian coordinate system)
- the area defined by those axes
- x and y axis labels
- a main label (title)
- Inherited from:
- Plots
Helper method to create a scene graph for a plot area. Thsi method create a Build, thus an object which can respond to events
Helper method to create a scene graph for a plot area. Thsi method create a Build, thus an object which can respond to events
The plot area is the complete area of a single 2D plot :
- x and y axes (Cartesian coordinate system)
- the area defined by those axes
- x and y axis labels
- a main label (title)
- Inherited from:
- Plots
- Inherited from:
- SimplePlots
- Inherited from:
- Plots3D
- Inherited from:
- Plots3D
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
Concrete fields
Implicits
Implicits
Inherited implicits
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- Tuples2
- Inherited from:
- ImplicitConversions
- Inherited from:
- ImplicitConversions
- Inherited from:
- ImplicitConversions
- Inherited from:
- ImplicitConversions
- Inherited from:
- ImplicitConversions
- Inherited from:
- ImplicitConversions
- Inherited from:
- ImplicitConversions
- Inherited from:
- ImplicitConversions
- Inherited from:
- ImplicitConversions
- Inherited from:
- DataTuples
- Inherited from:
- DataTuples
- Inherited from:
- DataTuples
- Inherited from:
- DataTuples
- Inherited from:
- DataTuples
- Inherited from:
- DataTuples
- Inherited from:
- DataTuples
- Inherited from:
- DataTuples
- Inherited from:
- DataTuples
- Inherited from:
- DataTuples
- Inherited from:
- DataTuples
- Inherited from:
- DataTuples
- Inherited from:
- DataTuples
- Inherited from:
- DataTuples
- Inherited from:
- DataTuples