View Source Contex.Plot (ContEx v0.5.0)

Manages the layout of various plot elements, including titles, axis labels, legends etc and calculates appropriate margins depending on the options set.

Link to this section Summary

Functions

Updates attributes for the plot. Takes a keyword list of attributes, which can include both "plot options" items passed individually as well as :title, :subtitle, :x_label and :y_label.

Sets the x-axis & y-axis labels for the plot. Empty string or nil will remove them.

Replaces the plot dataset and updates the plot content. Accepts a dataset or a list of lists/tuples representing the new data. The plot's dataset's original headers are preserved.

Replaces the plot dataset and updates the plot content. Accepts list of lists/tuples representing the new data and a list of strings with new headers.

Creates a new plot with specified plot content.

Creates a new plot with specified dataset and plot type. Other plot attributes can be set via a keyword list of options.

Updates plot options for the plot.

Updates the size for the plot

Sets the title and sub-title for the plot. Empty string or nil will remove the title or sub-title

Generates SVG output marked as safe for the configured plot.

Generates a complete XML document string.

Link to this section Types

@type plot_text() :: String.t() | nil
@type row() :: list() | tuple()
@type t() :: %Contex.Plot{
  default_style: term(),
  height: term(),
  margins: term(),
  plot_content: term(),
  plot_options: term(),
  subtitle: term(),
  title: term(),
  width: term(),
  x_label: term(),
  y_label: term()
}

Link to this section Functions

@spec attributes(
  t(),
  keyword()
) :: t()

Updates attributes for the plot. Takes a keyword list of attributes, which can include both "plot options" items passed individually as well as :title, :subtitle, :x_label and :y_label.

Link to this function

axis_labels(plot, x_label, y_label)

View Source
@spec axis_labels(t(), plot_text(), plot_text()) :: t()

Sets the x-axis & y-axis labels for the plot. Empty string or nil will remove them.

@spec dataset(t(), Contex.Dataset.t() | [row()]) :: t()

Replaces the plot dataset and updates the plot content. Accepts a dataset or a list of lists/tuples representing the new data. The plot's dataset's original headers are preserved.

Link to this function

dataset(plot, data, headers)

View Source
@spec dataset(t(), [row()], [String.t()]) :: t()

Replaces the plot dataset and updates the plot content. Accepts list of lists/tuples representing the new data and a list of strings with new headers.

Link to this function

new(width, height, plot_content)

View Source
@spec new(integer(), integer(), Contex.PlotContent.t()) :: t()

Creates a new plot with specified plot content.

Link to this function

new(dataset, type, width, height, attrs \\ [])

View Source
@spec new(Contex.Dataset.t(), module(), integer(), integer(), keyword()) :: t()

Creates a new plot with specified dataset and plot type. Other plot attributes can be set via a keyword list of options.

Link to this function

plot_options(plot, new_plot_options)

View Source

Updates plot options for the plot.

Link to this function

size(plot, width, height)

View Source
@spec size(t(), integer(), integer()) :: t()

Updates the size for the plot

Link to this function

titles(plot, title, subtitle)

View Source
@spec titles(t(), plot_text(), plot_text()) :: t()

Sets the title and sub-title for the plot. Empty string or nil will remove the title or sub-title

Generates SVG output marked as safe for the configured plot.

@spec to_xml(t()) :: iolist()

Generates a complete XML document string.