ContEx v0.3.0 Contex.Plot View Source

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.

Link to this section Types

Link to this type

plot_text()

View Source
plot_text() :: String.t() | nil
Link to this type

t()

View Source
t() :: %Contex.Plot{
  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

Link to this function

attributes(plot, attrs)

View Source
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
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.

Link to this function

dataset(plot, dataset)

View Source
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
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

Creates a new plot with specified plot content.

Link to this function

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

View Source
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
size(t(), integer(), integer()) :: t()

Updates the size for the plot

Link to this function

titles(plot, title, subtitle)

View Source
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.