API
Index¤
TidierPlots.aes
TidierPlots.geom_bar
TidierPlots.geom_boxplot
TidierPlots.geom_col
TidierPlots.geom_contour
TidierPlots.geom_density
TidierPlots.geom_errorbar
TidierPlots.geom_errorbarh
TidierPlots.geom_histogram
TidierPlots.geom_hline
TidierPlots.geom_label
TidierPlots.geom_line
TidierPlots.geom_path
TidierPlots.geom_point
TidierPlots.geom_smooth
TidierPlots.geom_step
TidierPlots.geom_text
TidierPlots.geom_tile
TidierPlots.geom_violin
TidierPlots.geom_vline
TidierPlots.label_bytes
TidierPlots.label_currency
TidierPlots.label_date
TidierPlots.label_log
TidierPlots.label_number
TidierPlots.label_ordinal
TidierPlots.label_percent
TidierPlots.label_pvalue
TidierPlots.label_scientific
TidierPlots.label_wrap
TidierPlots.position_facets
Reference - Exported functions¤
#
TidierPlots.aes
— Method.
aes(args...; kwargs...)
Details
TBD
#
TidierPlots.geom_bar
— Function.
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 toaes(...)
: 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
ORy
(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 :xdodge_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()
#
TidierPlots.geom_boxplot
— Function.
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 toaes(...)
: 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 withdodge
)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()
#
TidierPlots.geom_col
— Function.
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 toaes(...)
: 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 :xdodge_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))
#
TidierPlots.geom_contour
— Function.
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 toaes(...)
: 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)
#
TidierPlots.geom_density
— Function.
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 toaes(...)
: 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)
#
TidierPlots.geom_errorbar
— Function.
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 toaes(...)
: 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)
#
TidierPlots.geom_errorbarh
— Function.
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 toaes(...)
: 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)
#
TidierPlots.geom_histogram
— Function.
geom_histogram(aes(...), ...)
geom_histogram(plot::GGPlot, aes(...), ...)
Represents data as a histogram.
Arguments
plot::GGPlot
(optional): a plot object to add this geom toaes(...)
: 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)
#
TidierPlots.geom_hline
— Function.
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 toaes(...)
: 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()
#
TidierPlots.geom_label
— Function.
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 toaes(...)
: 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))
#
TidierPlots.geom_line
— Function.
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 toaes(...)
: 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()
#
TidierPlots.geom_path
— Function.
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 toaes(...)
: 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()
#
TidierPlots.geom_point
— Function.
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 toaes(...)
: 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)
#
TidierPlots.geom_smooth
— Method.
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 toaes(...)
: 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)
#
TidierPlots.geom_step
— Function.
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 toaes(...)
: 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()
#
TidierPlots.geom_text
— Function.
geom_text(aes(...), ...)
geom_text(plot::GGPlot, aes(...), ...)
Plot text on a graph.
Arguments
plot::GGPlot
(optional): a plot object to add this geom toaes(...)
: 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))
#
TidierPlots.geom_tile
— Function.
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 toaes(...)
: 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)
#
TidierPlots.geom_violin
— Function.
geom_(aes(...), ...)
geom_(plot::GGPlot, aes(...), ...)
Represents data as a violin plot.
Arguments
plot::GGPlot
(optional): a plot object to add this geom toaes(...)
: 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 withdodge
)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()
#
TidierPlots.geom_vline
— Function.
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 toaes(...)
: 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()
#
TidierPlots.label_bytes
— Method.
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 tolabel_number
.
Examples
labeler = label_bytes(units=:si)
labeler([1024, 2048]) # ["1.02 KB", "2.05 KB"]
#
TidierPlots.label_currency
— Method.
label_currency(;kwargs...)
Convert numeric values into currency strings.
Arguments
kwargs
: Additional keyword arguments passed tolabel_number
.
Examples
labeler = label_currency()
labeler([100, 200.75]) # ["$100", "$200.75"]
#
TidierPlots.label_date
— Method.
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"]
#
TidierPlots.label_log
— Method.
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 tolabel_number
.
Examples
labeler = label_log(base=10)
labeler([10, 100]) # ["10^1", "10^2"]
#
TidierPlots.label_number
— Method.
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 toformat
fromFormat.jl
Examples
labeler = label_number(precision=0, suffix="kg")
labeler([1500.12, -2000.12]) # ["1,500kg", "-2,000kg"]
#
TidierPlots.label_ordinal
— Method.
label_ordinal(;kwargs...)
Convert numeric values into ordinal strings (e.g., 1st, 2nd, 3rd).
Arguments
kwargs
: Additional keyword arguments passed tolabel_number
.
Examples
labeler = label_ordinal()
labeler([1, 2, 3]) # ["1st", "2nd", "3rd"]
#
TidierPlots.label_percent
— Method.
label_percent(;kwargs...)
Convert numeric values into percentage strings.
Arguments
kwargs
: Additional keyword arguments passed tolabel_number
.
Examples
labeler = label_percent()
labeler([0.1, 0.256]) # ["10%", "25.6%"]
#
TidierPlots.label_pvalue
— Method.
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 tolabel_number
.
Examples
labeler = label_pvalue()
labeler([0.0001, 0.05, 0.9999]) # ["<0.01", "0.05", ">0.99"]
#
TidierPlots.label_scientific
— Method.
label_scientific(;kwargs...)
Convert numeric values into scientific notation strings.
Arguments
kwargs
: Additional keyword arguments passed tolabel_number
.
Examples
labeler = label_scientific()
labeler([1000, 2000000]) # ["1e+03", "2e+06"]
#
TidierPlots.label_wrap
— Method.
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."]
Reference - Internal functions¤
#
TidierPlots.position_facets
— Function.
Internal function. Given a list of names and (optionally) some constraints, return the relative position of the facets and their labels.