Skip to content

API

Index¤

Reference - Exported functions¤

# TidierPlots.aesMethod.

aes(args...; kwargs...)

Details

TBD

source

# TidierPlots.geom_barFunction.

geom_bar(aes(...), ...)
geom_bar(plot::GGPlot, aes(...), ...)

Represent the counts of a grouping variable as columns.

Details

The columns are stacked by default, and the behavior can be changed with the "position" argument. The position can either be "stack" or "dodge". If the argument is "dodge", then a a grouping variable will also need to be supplied to aes. Alternatively you can supply the grouping variable to dodge within the aesthetic.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.BarPlot)

Required Aesthetics

  • x OR y (not both)

Optional Aesthetics (see aes)

  • color / colour
  • strokecolor / strokecolour
  • dodge
  • group

Optional Arguments

  • position: "stack" (default) or "dodge"
  • stroke / strokewidth
  • strokecolor / strokecolour
  • direction: :y (default) or :x
  • dodge_gap
  • gap

Examples

# vertical bar plot
ggplot(penguins) + geom_bar(@aes(x = species))

# horizontal bar plot
ggplot(penguins) + geom_bar(@aes(y = species))

ggplot(penguins, @aes(x = species, color=sex, dodge=sex)) + geom_bar()

source

# TidierPlots.geom_boxplotFunction.

geom_boxplot(aes(...), ...)
geom_boxplot(plot::GGPlot, aes(...), ...)

Compactly displays the distribution of continuous data.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.BoxPlot)

Required Aesthetics

  • x (integer or categorical)
  • y (numeric)

Optional Aesthetics (see aes)

  • color / colour (used in conjunction with dodge)
  • dodge

Optional Arguments

  • orientation=:vertical: orientation of box (:vertical or :horizontal)
  • width=1
  • gap=0.2
  • show_notch=false
  • nothchwidth=0.5
  • show_median=true
  • dodge_gap=0.03

Examples

ggplot(penguins, @aes(x=species, y=bill_length_mm)) +
    geom_boxplot()

ggplot(penguins, @aes(x=species, y=bill_length_mm)) +
    geom_boxplot(orientation=:horizontal)

ggplot(penguins, @aes(x=species, y=bill_length_mm, dodge=sex, color=sex)) +
    geom_boxplot()

source

# TidierPlots.geom_colFunction.

geom_col(aes(...), ...)
geom_col(plot::GGPlot, aes(...), ...)

Represent data as columns.

Details

The columns are stacked by default, and the behavior can be changed with the "position" argument. The position can either be "stack" or "dodge". If the argument is "dodge", then a a grouping variable will also need to be supplied to aes. Alternatively you can supply the grouping variable to dodge within the aesthetic.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.BarPlot)

Required Aesthetics

  • x
  • y

Optional Aesthetics (see aes)

  • color / colour
  • strokecolor / strokecolour
  • dodge
  • group

Optional Arguments

  • position: "stack" (default) or "dodge"
  • stroke / strokewidth
  • strokecolor / strokecolour
  • direction: :y (default) or :x
  • dodge_gap
  • gap

Examples

df = @chain penguins begin
    @group_by(species, sex)
    @summarize(mean_bill_length_mm = mean(bill_length_mm))
    @ungroup()
end

ggplot(df) +
    geom_col(@aes(x = species, y = mean_bill_length_mm))

# dodge using the group and position arguments
ggplot(df) +
    geom_col(@aes(x = species, y = mean_bill_length_mm, group = sex),
             position="dodge")

# dodge using the dodge aesthetic
ggplot(df) +
    geom_col(@aes(x = species, y = mean_bill_length_mm, dodge = sex))

# color based on grouping variable
ggplot(df) +
    geom_col(@aes(x = species, y = mean_bill_length_mm, color = sex))

source

# TidierPlots.geom_contourFunction.

geom_contour(aes(...), ...)
geom_contour(plot::GGPlot, aes(...), ...)

Represents a grid of data as smooth curves of a surface.

Details

This is geom is equivalent to ggplot2::ggplot(df, aes(x, y, z = density)). Only the x and y aesthetics are required.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.Contour)

Required Aesthetics

  • x
  • y

Optional Aesthetics (see aes)

  • NA

Optional Arguments

  • color / colour
  • colormap / palette
  • levels
  • linewidth
  • linestyle / linetype

Examples

ggplot(penguins, @aes(x = bill_length_mm, y = bill_depth_mm)) +
    geom_contour(levels = 10)

source

# TidierPlots.geom_densityFunction.

geom_density(aes(...), ...)
geom_density(plot::GGPlot, aes(...), ...)

Represent data as a smooth density curve.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.Density)

Required Aesthetics

  • x

Optional Aesthetics (see aes)

  • NA

Optional Arguments

  • color / colour
  • colormap / palette
  • strokecolor / strokecolour
  • strokewidth / stroke
  • linestyle / linetype
  • direction=:x
  • npoints=200

Examples

ggplot(penguins, @aes(x=bill_length_mm)) + geom_density()

ggplot(penguins, @aes(x=bill_length_mm)) +
    geom_density(color = (:red, 0.3), strokecolor = :red, stroke = 2)

source

# TidierPlots.geom_errorbarFunction.

geom_errorbar(aes(...), ...)
geom_errorbar(plot::GGPlot, aes(...), ...)

Represents data as a vertical interval.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.Rangebars)

Required Aesthetics

  • x
  • ymin
  • ymax

Optional Aesthetics (see aes)

  • NA

Optional Arguments

  • color / colour
  • direction=:y
  • linewidth
  • whiskerwidth / width

Examples

df = DataFrame(
    trt   = [1, 1, 2, 2],
    resp  = [1, 5, 3, 4],
    group = [1, 2, 1, 2],
    lower = [0.8, 4.6, 2.4, 3.6],
    upper = [1.1, 5.3, 3.3, 4.2],
)

ggplot(df, @aes(x = trt, ymin = lower, ymax = upper)) +
    geom_errorbar(width=20, linewidth=2)

source

# TidierPlots.geom_errorbarhFunction.

geom_errorbarh(aes(...), ...)
geom_errorbarh(plot::GGPlot, aes(...), ...)

Represents data as a horizontal interval.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.Rangebars)

Required Aesthetics

  • y
  • xmin
  • xmax

Optional Aesthetics (see aes)

  • NA

Optional Arguments

  • color / colour
  • direction=:x
  • linewidth
  • whiskerwidth / width

Examples

df = DataFrame(
    trt   = [1, 1, 2, 2],
    resp  = [1, 5, 3, 4],
    group = [1, 2, 1, 2],
    lower = [0.8, 4.6, 2.4, 3.6],
    upper = [1.1, 5.3, 3.3, 4.2],
)

ggplot(df, @aes(y = trt, xmin = lower, xmax = upper)) +
    geom_errorbarh(width=20, linewidth=2)

source

# TidierPlots.geom_histogramFunction.

geom_histogram(aes(...), ...)
geom_histogram(plot::GGPlot, aes(...), ...)

Represents data as a histogram.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.Hist)

Required Aesthetics

  • x

Optional Aesthetics (see aes)

  • NA

Optional Arguments

  • bins
  • normalization
  • color / colour
  • stroke / strokewidth
  • strokecolor / strokecolour

Examples

ggplot(penguins, @aes(x = bill_length_mm)) +
    geom_histogram()

ggplot(penguins, @aes(x = bill_length_mm)) +
    geom_histogram(normalization=:probability, bins=20)

source

# TidierPlots.geom_hlineFunction.

geom_hline(aes(...), ...)
geom_hline(plot::GGPlot, aes(...), ...)

Plot a horizontal line at the given y-intercept(s).

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.HLines)

Required Aesthetics

  • NA

Optional Aesthetics (see aes)

  • yintercept(s)
  • color / colour

Optional Arguments

  • yintercept(s)
  • color / colour
  • linewidth
  • linestyle / linetype
  • colormap / palette
  • alpha

Examples

# Plot only a single y-intercept
ggplot() + geom_hline(yintercept = 3)

# Plot multiple y-intercepts
ggplot() + geom_hline(yintercept = [-1, 4])

# Plot multiple y-intercepts mapped to a column
df = DataFrame(y = rand(4))
ggplot(df, @aes(yintercept = y)) + geom_hline()

source

# TidierPlots.geom_labelFunction.

geom_label(aes(...), ...)
geom_label(plot::GGPlot, aes(...), ...)

Plot text on a graph.

ggplot2 deviation

Currently this method is the same as geom_text, and does not put the text in a rectangle like in ggplot2.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.Text)

Required Aesthetics

  • x
  • y
  • text

Optional Aesthetics (see aes)

  • color / colour

Optional Arguments

  • color / colour
  • colormap / palette
  • align: tuple of positions (e.g. (:left, :bottom))
  • font
  • justification
  • rotation
  • fontsize
  • strokewidth
  • strokecolor
  • glowwidth / glow
  • glowcolor / glowcolour
  • word_wrap_width
  • alpha

Examples

df = DataFrame(
    x = [1,1,2,2],
    y = [1,2,1,2],
    t = ["A", "B", "C", "D"]
)

ggplot(df, @aes(x=x, y=y, text=t, color=t)) + geom_label()

ggplot(df, @aes(x=x, y=y, text=t, color=t)) +
    geom_label(fontsize=24, align=(:left, :bottom), font=:bold) +
    geom_point() +
    lims(x = (0, 3), y = (0, 3))

source

# TidierPlots.geom_lineFunction.

geom_line(aes(...), ...)
geom_line(plot::GGPlot, aes(...), ...)

Represents data as connected points in the order of the variable on the x-axis.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.Lines)

Required Aesthetics

  • x
  • y

Optional Aesthetics (see aes)

  • color / colour

Optional Arguments

  • color / colour
  • colormap / palette
  • linestyle / linetype
  • linewidth
  • alpha

Examples

xs = range(0, 2pi, length=30)
df = DataFrame(x = xs, y = sin.(xs))

ggplot(df, @aes(x = x, y = y)) + geom_line()

source

# TidierPlots.geom_pathFunction.

geom_path(aes(...), ...)
geom_path(plot::GGPlot, aes(...), ...)

Represents data as connected points in the order in which they appear in the data.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.Lines)

Required Aesthetics

  • x
  • y

Optional Aesthetics (see aes)

  • color / colour

Optional Arguments

  • color / colour
  • colormap / palette
  • linestyle / linetype
  • linewidth
  • alpha

Examples

ggplot(penguins, @aes(x = bill_length_mm, y = bill_depth_mm)) +
    geom_path()

source

# TidierPlots.geom_pointFunction.

geom_point(aes(...), ...)
geom_point(plot::GGPlot, aes(...), ...)

Represents data as pairs of (x, y) points.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.Scatter)

Required Aesthetics

  • x
  • y

Optional Aesthetics (see aes)

  • color / color

Optional Arguments

  • color / colour
  • colormap / palette
  • marker / shape
  • markersize / size
  • strokewidth / stroke
  • strokecolor / strokecolour
  • glowwidth / glow
  • glowcolor / glowcolour
  • alpha

Examples

ggplot(penguins, @aes(x = bill_length_mm, y = bill_depth_mm)) + geom_point()

ggplot(penguins, @aes(x = bill_length_mm, y = bill_depth_mm)) +
    geom_point(@aes(color = sex), size=20, stroke=1, alpha=0.6)

source

# TidierPlots.geom_smoothMethod.

geom_smooth(aes(...), ...)
geom_smooth(plot::GGPlot, aes(...), ...)

Represent data as a smoothed or linear fit.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.Lines)

Required Aesthetics

  • x
  • y

Optional Aesthetics (see aes)

  • NA

Optional Arguments

  • method: either "smooth" (default, loess fit) or "lm" (linear fit)
  • color / colour
  • linewidth
  • alpha
  • linestyle / linetype

Examples

xs = range(0, 2pi, length=30)
ys = sin.(xs) .+ randn(length(xs)) * 0.5
df = DataFrame(x = xs, y = ys)

ggplot(df, @aes(x = x, y = y)) + geom_smooth() + geom_point()

ggplot(penguins, @aes(x = bill_length_mm, y = bill_depth_mm)) +
    geom_smooth(color=:red, linewidth=10, alpha=0.5)

source

# TidierPlots.geom_stepFunction.

geom_step(aes(...), ...)
geom_step(plot::GGPlot, aes(...), ...)

Represents data as a stairstep plot.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.Stairs)

Required Aesthetics

  • x
  • y

Optional Aesthetics (see aes)

  • color / colour

Optional Arguments

  • color / colour
  • colormap / palette
  • linestyle / linetype
  • linewidth
  • alpha

Examples

xs = range(0, 2pi, length=30)
df = DataFrame(x = xs, y = sin.(xs))

ggplot(df, @aes(x = x, y = y)) + geom_step()

source

# TidierPlots.geom_textFunction.

geom_text(aes(...), ...)
geom_text(plot::GGPlot, aes(...), ...)

Plot text on a graph.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.Text)

Required Aesthetics

  • x
  • y
  • text

Optional Aesthetics (see aes)

  • color / colour

Optional Arguments

  • color / colour
  • colormap / palette
  • align: tuple of positions (e.g. (:left, :bottom))
  • font
  • justification
  • rotation
  • fontsize
  • strokewidth
  • strokecolor
  • glowwidth / glow
  • glowcolor / glowcolour
  • word_wrap_width
  • alpha

Examples

df = DataFrame(
    x = [1,1,2,2],
    y = [1,2,1,2],
    t = ["A", "B", "C", "D"]
)

ggplot(df, @aes(x=x, y=y, text=t, color=t)) + geom_text()

ggplot(df, @aes(x=x, y=y, text=t, color=t)) +
    geom_text(fontsize=24, align=(:left, :bottom), font=:bold) +
    geom_point() +
    lims(x = (0, 3), y = (0, 3))

source

# TidierPlots.geom_tileFunction.

geom_tile(aes(...), ...)
geom_tile(plot::GGPlot, aes(...), ...)

Plots a heatmap as a collection of rectangles.

Details

x, y, and z must all be the same length, and there must be no duplicate (x, y) pairs. You can think of x, y, and z as triples of the form (x, y, f(x, y)).

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.Heatmap)

Required Aesthetics

  • x
  • y
  • z

Optional Aesthetics (see aes)

  • NA

Optional Arguments

  • interpolate=false
  • colormap / palette
  • alpha

Examples

function mandelbrot(x, y)
    z = c = x + y*im
    for i in 1:30.0; abs(z) > 2 && return i; z = z^2 + c; end; 0
end

xs = -2:0.001:1
ys = -1.1:0.001:1.1
xys = Iterators.product(xs, ys) |> collect |> vec
zs = map(xy -> mandelbrot(xy[1], xy[2]), xys)

df = DataFrame(
    x = first.(xys),
    y = last.(xys),
    z = zs
)

ggplot(df, @aes(x = x, y = y, z = z)) + geom_tile(colormap = :deep)

source

# TidierPlots.geom_violinFunction.

geom_(aes(...), ...)
geom_(plot::GGPlot, aes(...), ...)

Represents data as a violin plot.

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.Violin)

Required Aesthetics

  • x (integer or categorical)
  • y (numeric)

Optional Aesthetics (see aes)

  • color / colour (used in conjunction with dodge)
  • dodge

Optional Arguments

  • orientation=:vertical: orientation of box (:vertical or :horizontal)
  • width=1
  • gap=0.2
  • show_notch=false
  • nothchwidth=0.5
  • show_median=true
  • dodge_gap=0.03

Examples

ggplot(penguins, @aes(x=species, y=bill_length_mm)) +
    geom_violin()

ggplot(penguins, @aes(x=species, y=bill_length_mm)) +
    geom_violin(orientation=:horizontal)

ggplot(penguins, @aes(x=species, y=bill_length_mm, dodge=sex, color=sex)) +
    geom_violin()

source

# TidierPlots.geom_vlineFunction.

geom_vline(aes(...), ...)
geom_vline(plot::GGPlot, aes(...), ...)

Plot a horizontal line at the given y-intercept(s).

Arguments

  • plot::GGPlot (optional): a plot object to add this geom to
  • aes(...): the names of the columns in the DataFrame that will be used in the mapping
  • ...: options that are not mapped to a column (passed to Makie.VLines)

Required Aesthetics

  • NA

Optional Aesthetics (see aes)

  • xintercept(s)
  • color / colour

Optional Arguments

  • xintercept(s)
  • color / colour
  • linewidth
  • linestyle / linetype
  • colormap / palette
  • alpha

Examples

# Plot only a single x-intercept
ggplot() + geom_vline(xintercept = 3)

# Plot multiple x-intercepts
ggplot() + geom_vline(xintercept = [-1, 4])

# Plot multiple x-intercepts mapped to a column
df = DataFrame(x = rand(4))
ggplot(df, @aes(xintercept = x)) + geom_vline()

source

# TidierPlots.label_bytesMethod.

label_bytes(;units=:si, kwargs...)

Convert numeric values into human-readable strings representing byte sizes.

Arguments

  • units: Can be :si for SI units (powers of 10), :binary for binary units (powers of 1024), or a specific unit string (e.g., MB, GiB).
  • kwargs...: Additional keyword arguments passed to label_number.

Examples

labeler = label_bytes(units=:si)
labeler([1024, 2048]) # ["1.02 KB", "2.05 KB"]

source

# TidierPlots.label_currencyMethod.

label_currency(;kwargs...)

Convert numeric values into currency strings.

Arguments

  • kwargs: Additional keyword arguments passed to label_number.

Examples

labeler = label_currency()
labeler([100, 200.75]) # ["$100", "$200.75"]

source

# TidierPlots.label_dateMethod.

label_date(;format="m/d/Y")

Convert Date or DateTime values into formatted strings.

Arguments

  • format: A date format string.

Examples

labeler = label_date(format="Y-m-d")
labeler([Date(2020, 1, 1)]) # ["2020-1-1"]

source

# TidierPlots.label_logMethod.

label_log(;base=10, kwargs...)

Convert numeric values into logarithmic strings with a specified base.

Arguments

  • base: The logarithmic base.
  • kwargs: Additional keyword arguments passed to label_number.

Examples

labeler = label_log(base=10)
labeler([10, 100]) # ["10^1", "10^2"]

source

# TidierPlots.label_numberMethod.

label_number(;precision=2, scale=1, prefix="", suffix="", decimal_mark=".", comma_mark=",", style_positive=:none, style_negative=:hyphen, kwargs...)

Format numeric values as strings with various styling options.

Arguments

  • precision: Number of decimal places.
  • scale: Scaling factor applied to the numbers before formatting.
  • prefix: String to prepend to the number.
  • suffix: String to append to the number.
  • decimal_mark: Character to use as the decimal point.
  • comma_mark: Character to use as the thousands separator.
  • style_positive: Style for positive numbers (:none, :plus, :space).
  • style_negative: Style for negative numbers (:hyphen, :parens).
  • kwargs: Additional keyword arguments passed on to format from Format.jl

Examples

labeler = label_number(precision=0, suffix="kg")
labeler([1500.12, -2000.12]) # ["1,500kg", "-2,000kg"]

source

# TidierPlots.label_ordinalMethod.

label_ordinal(;kwargs...)

Convert numeric values into ordinal strings (e.g., 1st, 2nd, 3rd).

Arguments

  • kwargs: Additional keyword arguments passed to label_number.

Examples

labeler = label_ordinal()
labeler([1, 2, 3]) # ["1st", "2nd", "3rd"]

source

# TidierPlots.label_percentMethod.

label_percent(;kwargs...)

Convert numeric values into percentage strings.

Arguments

  • kwargs: Additional keyword arguments passed to label_number.

Examples

labeler = label_percent()
labeler([0.1, 0.256]) # ["10%", "25.6%"]

source

# TidierPlots.label_pvalueMethod.

label_pvalue(;precision=2, kwargs...)

Format p-values, handling very small or large values with special notation.

Arguments

  • precision: Number of decimal places for thresholding small values.
  • kwargs: Additional keyword arguments passed to label_number.

Examples

labeler = label_pvalue()
labeler([0.0001, 0.05, 0.9999]) # ["<0.01", "0.05", ">0.99"]

source

# TidierPlots.label_scientificMethod.

label_scientific(;kwargs...)

Convert numeric values into scientific notation strings.

Arguments

  • kwargs: Additional keyword arguments passed to label_number.

Examples

labeler = label_scientific()
labeler([1000, 2000000]) # ["1e+03", "2e+06"]

source

# TidierPlots.label_wrapMethod.

label_wrap(width)

Wrap text strings to a specified width, breaking at spaces.

Arguments

  • width: The maximum number of characters in a line before wrapping.

Examples

labeler = label_wrap(10)
labeler(["This is a long sentence."]) # ["This is a
long
sentence."]

source

Reference - Internal functions¤

# TidierPlots.position_facetsFunction.

Internal function. Given a list of names and (optionally) some constraints, return the relative position of the facets and their labels.

source