Plot

class Plot(cfg: Config) extends Grammar[Plot]

Plotting engine based on Vega-Lite (https://vega.github.io/vega-lite/). Required DataFrame columns are automatically encoded and embedded.

The syntax keeps 1:1 to the Vega-Lite JSON grammar https://vega.github.io/vega-lite/docs/ with a few adaptions:

  • Top level specifications are added via methods (e.g. .title(...)).
  • The mark definition is on top level (e.g. .bar(...)) rather than part of a mark definition.
  • The encoding channel definitions are on top level (e.g. .color(...)) rather than part of encoding.

Top level definitions usually contain named parameters with following data types:

  • Number (Int, Float, Double),
  • String,
  • Struct, a complex struct-like object with one or more properties (of any type listed here),
  • Seq[T], a sequence (list) where the inner type T is one of the types above,
  • null.

Due to the reserved keyword type in Scala the following parameter name replacements were made:

  • Please use as where the JSON element is named type (e.g. in encodings and projection).
  • Please use set where the JSON element is named as (e.g. in transform).
See also
Since

0.1.0

Companion
object
class Grammar[Plot]
trait Dynamic
class Object
trait Matchable
class Any

Value members

Concrete methods

def autosize(struct: Struct): Plot

How the visualization size should be determined. If a string, should be one of "pad", "fit" or "none".

How the visualization size should be determined. If a string, should be one of "pad", "fit" or "none".

https://vega.github.io/vega-lite/docs/spec.html#top-level

Value Params
struct

String or Struct. https://vega.github.io/vega-lite/docs/size.html#autosize

Since

0.1.0

def background(struct: Struct): Plot

Color property to use as the background of the entire view.

Color property to use as the background of the entire view.

https://vega.github.io/vega-lite/docs/spec.html#top-level

Value Params
struct

Color definition.

Since

0.1.0

def config: Plot

Sets configuration object.

Since

0.1.0

def html: String

Renders the plot as HTML.

Renders the plot as HTML.

Returns

HTML as a string with the embedded plot.

Since

0.1.0

def json: String

Plot specification in Vega-Lite's JSON grammar.

Plot specification in Vega-Lite's JSON grammar.

Returns

JSON as string.

Since

0.1.0

def padding(struct: Struct): Plot

The default visualization padding (in pixels).

The default visualization padding (in pixels).

https://vega.github.io/vega-lite/docs/spec.html#top-level

Value Params
struct

Number or Struct.

Since

0.1.0

Example
.padding(Struct(left= 5, top=5, right= 5, bottom=5))

Sets optional metadata.

def write(path: String): Unit

Writes plot to a HTML file.

Writes plot to a HTML file.

Value Params
path

File path.

Since

0.1.0

def write(writer: Writer): Unit

Writes the plots as HTML.

Writes the plots as HTML.

Value Params
writer

Writer object.

Since

0.1.0

Inherited methods

def align(struct: Struct*): Plot

The alignment to apply to grid rows and columns.

The alignment to apply to grid rows and columns.

Value Params
struct

https://vega.github.io/vega-lite/docs/spec.html#common

Since

0.1.0

Inherited from
Grammar
def applyDynamicNamed(method: String)(kwargs: (String, Struct)*): Plot
Inherited from
Grammar
def arc: Plot
def bar: Plot
def bounds(struct: Struct*): Plot

The bounds calculation method to use for determining the extent of a sub-plot.

The bounds calculation method to use for determining the extent of a sub-plot.

Value Params
struct

https://vega.github.io/vega-lite/docs/spec.html#common

Since

0.1.0

Inherited from
Grammar
def center(struct: Struct*): Plot

Indicating if subviews should be centered relative to their respective rows or columns.

Indicating if subviews should be centered relative to their respective rows or columns.

Value Params
struct

https://vega.github.io/vega-lite/docs/spec.html#common

Since

0.1.0

Inherited from
Grammar
def color(field: String, as: String, aggregate: Struct, bin: Struct, condition: Struct, datum: Struct, legend: Struct, scale: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot
def concat(columns: Int, layers: Layer*): Plot

Concatenation of plots.

Value Params
layers

Layers.

See also
Since

0.1.0

Inherited from
Grammar
def custom(name: String, struct: Struct): Plot

Custom element.

Custom element.

Value Params
name

Element name.

struct

Definition.

Since

0.1.0

Inherited from
Grammar
def customEncoding(name: String, field: String, struct: Struct): Plot

Custom encoding channel element.

Custom encoding channel element.

Value Params
field

Column or field name.

name

Encoding name.

struct

Definition.

Since

0.1.0

Inherited from
Grammar
def data: Plot

Custom data definition.

Since

0.1.0

Inherited from
Grammar

DataFrame referenced by column names for Plot or Layer.

DataFrame referenced by column names for Plot or Layer.

Value Params
df

DataFrame.

Since

0.1.0

Inherited from
Grammar
def dataInclude(field: String*): Plot

Embeds additional DataFrame columns in the data.

Embeds additional DataFrame columns in the data.

Value Params
field

Column name.

Since

0.1.0

Inherited from
Grammar
def description(field: String, as: String, aggregate: Struct, bandPosition: Struct, bin: Struct, condition: Struct, datum: Struct, format: Struct, formatType: String, timeUnit: Struct, title: Struct, value: Struct): Plot
def description(string: String): Plot

Description of this mark for commenting purpose.

Description of this mark for commenting purpose.

https://vega.github.io/vega-lite/docs/spec.html#common

Value Params
string

Description.

Since

0.1.0

Inherited from
Grammar
def detail(field: String, as: String): Plot

Defines an additional grouping field for grouping data without mapping the field to any visual properties.

Defines an additional grouping field for grouping data without mapping the field to any visual properties.

https://vega.github.io/vega-lite/docs/encoding.html#detail

Value Params
as

https://vega.github.io/vega-lite/docs/type.html

field

Column or field name.

Since

0.1.0

Inherited from
Grammar
def details(fields: (String, String)*): Plot

Defines additional grouping fields for grouping data without mapping the fields to any visual properties.

Defines additional grouping fields for grouping data without mapping the fields to any visual properties.

https://vega.github.io/vega-lite/docs/encoding.html#detail

Value Params
fields

Tuples of field and as (https://vega.github.io/vega-lite/docs/type.html). Example:

.details( "group3" -> Nominal, "group4" -> Nominal)
Since

0.1.0

Inherited from
Grammar
def hconcat(layers: Layer*): Plot

Horizontal concatenation of plots.

Horizontal concatenation of plots.

https://vega.github.io/vega-lite/docs/concat.html

Value Params
layers

Layers.

Since

0.1.0

Inherited from
Grammar
def height(px: Int): Plot

Height of plot.

Value Params
px

Height of plot.

Since

0.1.0

Inherited from
Grammar
def href(field: String, as: String, aggregate: Struct, bandPosition: Struct, bin: Struct, condition: Struct, datum: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot
def key(field: String, as: String, aggregate: Struct, bandPosition: Struct, bin: Struct, datum: Struct, format: Struct, formatType: String, timeUnit: Struct, title: Struct, value: Struct): Plot
def latitude(field: String, as: String, aggregate: Struct, bandPosition: Struct, bin: Struct, datum: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot
def latitude2(field: String, as: String, aggregate: Struct, bandPosition: Struct, bin: Struct, datum: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot

Latitude2 position for geographically projected ranged "area", "bar", "rect", and "rule"

def layer(layers: Layer*): Plot

Adds multiple (overlaying) layers .

Adds multiple (overlaying) layers .

https://vega.github.io/vega-lite/docs/layer.html

Value Params
layers

Layers.

Since

0.1.0

Note

The layering mode is applied to all defined layers.

Inherited from
Grammar
def longitude(field: String, as: String, aggregate: Struct, bandPosition: Struct, bin: Struct, datum: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot
def longitude2(field: String, as: String, aggregate: Struct, bandPosition: Struct, bin: Struct, datum: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot

Longitude2 position for geographically projected ranged "area", "bar", "rect", and "rule".

def name(name: String): Plot

Name of the visualization for reference.

Name of the visualization for reference.

https://vega.github.io/vega-lite/docs/spec.html#common

Value Params
name

Name.

Since

0.1.0

Inherited from
Grammar
def order(fields: (String, Struct)*): Plot

Multi-field order definition.

Value Params
fields

Tuples of field names and Struct.

Since

0.1.0

Inherited from
Grammar
def order(field: String, as: String, aggregate: Struct, bandPosition: Struct, bin: Struct, condition: Struct, datum: Struct, sort: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot

The order defines a data field that is used to sorts stacking order for stacked charts and the order of data points in line marks for connected scatterplots.

def param(struct: Struct*): Plot

Parameters can either be simple variables or more complex selections that map user input to data queries.

Parameters can either be simple variables or more complex selections that map user input to data queries.

Value Params
struct

https://vega.github.io/vega-lite/docs/parameter.html

Since

0.1.0

Inherited from
Grammar

Sets cartographic projection.

Since

0.1.0

Inherited from
Grammar
def radius(field: String, as: String, aggregate: Struct, bandPosition: Struct, bin: Struct, datum: Struct, scale: Struct, sort: Struct, stack: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot
def radius2(field: String, as: String, aggregate: Struct, bandPosition: Struct, bin: Struct, datum: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot

Radius2 determines the position or interval on polar coordinates for arc and text marks.

def resolve(scale: Struct, axis: Struct, legend: Struct): Plot

Scale, axis, and legend resolutions for view composition specifications.

def spacing(struct: Struct*): Plot

The spacing (in pixels) between sub-views of the composition operator.

The spacing (in pixels) between sub-views of the composition operator.

Value Params
struct

https://vega.github.io/vega-lite/docs/spec.html#common

Since

0.1.0

Inherited from
Grammar
def theta(field: String, as: String, aggregate: Struct, bandPosition: Struct, bin: Struct, datum: Struct, scale: Struct, sort: Struct, stack: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot
def theta2(field: String, as: String, aggregate: Struct, bandPosition: Struct, bin: Struct, datum: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot

Theta2 determines the interval on polar coordinates for arc and text marks.

def title(title: Struct): Plot
def tooltips(fields: (String, Struct)*): Plot

Multi-field tooltip text to show upon mouse hover.

Multi-field tooltip text to show upon mouse hover.

https://vega.github.io/vega-lite/docs/tooltip.html

Value Params
fields

Tuples of field names and Struct(field, as, aggregate, bandPosition, bin, condition, datum, format, formatType, timeUnit, title, value) (see tooltip for details).

Since

0.1.0

Example
.tooltips(
 "x" -> Struct(field = "x", as = Temporal, title = "X Value"),
 "y" -> Struct(field = "y", as = Nominal, title = "Y Value")
)
Inherited from
Grammar
def transform(struct: Struct*): Plot

Data transformations such as filter and new field calculation.

Data transformations such as filter and new field calculation.

Value Params
struct

https://vega.github.io/vega-lite/docs/transform.html

Since

0.1.0

Note

Use "set" to set a new field/variable.

Example
.transform(
 Struct(calculate="datum.x*datum.x", set="x2"),
 Struct(filter="datum.x2 < 100")
 )
Inherited from
Grammar
def vconcat(layers: Layer*): Plot

Vertical concatenation of plots.

Vertical concatenation of plots.

https://vega.github.io/vega-lite/docs/concat.html

Value Params
layers

Layers.

Since

0.1.0

Inherited from
Grammar
def view: Plot

Defines the view background’s fill and stroke.

Defines the view background’s fill and stroke.

https://vega.github.io/vega-lite/docs/spec.html#view-background

Since

0.1.0

Inherited from
Grammar
def width(px: Int): Plot

Width of plot.

Value Params
px

Width of plot.

Since

0.1.0

Inherited from
Grammar
def x2(field: String, as: String, aggregate: Struct, bin: Struct, bandPosition: Struct, datum: Struct, impute: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot
def xOffset(field: String, as: String, aggregate: Struct, bandPosition: Struct, bin: Struct, datum: Struct, scale: Struct, sort: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot
def y2(field: String, as: String, aggregate: Struct, bin: Struct, bandPosition: Struct, datum: Struct, impute: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot
def yOffset(field: String, as: String, aggregate: Struct, bandPosition: Struct, bin: Struct, datum: Struct, scale: Struct, sort: Struct, timeUnit: Struct, title: Struct, value: Struct): Plot