Text Backend Examples

Here, we can see some examples of text tables generated by PrettyTables.jl. The A object, when referenced, is defined as:

julia> A = Any[
    1    false      1.0     0x01
    2     true      2.0     0x02
    3    false      3.0     0x03
    4     true      4.0     0x04
    5    false      5.0     0x05
    6     true      6.0     0x06
]

julia> pretty_table(A)
Text Example 01
julia> pretty_table(A; style = TextTableStyle(; table_border = crayon"yellow"))
Text Example 02
julia> data = [
    10.0 6.5
     3.0 3.0
     0.1 1.0
]

julia> row_labels = [
    "Atmospheric drag"
    "Gravity gradient"
    "Solar radiation pressure"
]

julia> column_labels = [
    [MultiColumn(2, "Value", :c)],
    [
        "Torque [10⁻⁶ Nm]",
        "Angular Momentum [10⁻³ Nms]"
    ]
]

julia> pretty_table(
    data;
    column_labels,
    merge_column_label_cells = :auto,
    row_labels,
    stubhead_label = "Effect",
    style = TextTableStyle(;
        first_line_merged_column_label = crayon"bold yellow",
        stubhead_label = crayon"bold yellow",
        summary_row_label = crayon"bold cyan"
    ),
    summary_row_labels = ["Total"],
    summary_rows = [(data, i) -> sum(data[:, i])],
    table_format = TextTableFormat(;
        @text__no_vertical_lines,
        horizontal_lines_at_column_labels = [1],
        vertical_line_after_row_label_column = true
    ),
)
Text Example 03
julia> t = 0:1:20

julia> data = hcat(t, ones(length(t) ), t, 0.5.*t.^2);

julia> column_labels = [
    ["Time", "Acceleration", "Velocity", "Distance"],
    [ "[s]",     "[m / s²]",  "[m / s]",      "[m]"]
]

julia> hl_p = TextHighlighter(
    (data, i, j) -> (j == 4) && (data[i, j] > 9),
    crayon"bold blue"
)

julia> hl_v = TextHighlighter(
    (data, i, j) -> (j == 3) && (data[i, j] > 9),
    crayon"bold red"
)

julia> pretty_table(
    data;
    column_labels = column_labels,
    highlighters  = [hl_p, hl_v],
    style = TextTableStyle(;
        first_line_column_label = crayon"bold yellow",
    )
)
Text Example 04