Pre-defined Formats
The text backend has some predefined borders and formats to print the tables.
Borders
We can change the printed table borders using the parameter borders
in the structure TextTableFormat
passed to the keyword table_format
.
text_table_borders__ascii_dots
julia> pretty_table( data; backend = :text, table_format = TextTableFormat(borders = text_table_borders__ascii_dots) )
..................................... : Col. 1 : Col. 2 : Col. 3 : Col. 4 : :........:........:........:........: : 1 : false : 1.0 : 1 : : 2 : true : 2.0 : 2 : : 3 : false : 3.0 : 3 : :........:........:........:........:
text_table_borders__ascii_rounded
julia> pretty_table( data; backend = :text, table_format = TextTableFormat(borders = text_table_borders__ascii_rounded) )
.--------.--------.--------.--------. | Col. 1 | Col. 2 | Col. 3 | Col. 4 | :--------+--------+--------+--------: | 1 | false | 1.0 | 1 | | 2 | true | 2.0 | 2 | | 3 | false | 3.0 | 3 | '--------'--------'--------'--------'
text_table_borders__borderless
julia> pretty_table( data; backend = :text, table_format = TextTableFormat(borders = text_table_borders__borderless) )
Col. 1 Col. 2 Col. 3 Col. 4 1 false 1.0 1 2 true 2.0 2 3 false 3.0 3
text_table_borders__compact
julia> pretty_table( data; backend = :text, table_format = TextTableFormat(borders = text_table_borders__compact) )
-------- -------- -------- -------- Col. 1 Col. 2 Col. 3 Col. 4 -------- -------- -------- -------- 1 false 1.0 1 2 true 2.0 2 3 false 3.0 3 -------- -------- -------- --------
text_table_borders__matrix
julia> pretty_table( data; backend = :text, table_format = TextTableFormat(borders = text_table_borders__matrix) )
┌ ┬ ┬ ┬ ┐ │ Col. 1 │ Col. 2 │ Col. 3 │ Col. 4 │ │ │ │ │ │ │ 1 │ false │ 1.0 │ 1 │ │ 2 │ true │ 2.0 │ 2 │ │ 3 │ false │ 3.0 │ 3 │ └ ┴ ┴ ┴ ┘
text_table_borders__mysql
julia> pretty_table( data; backend = :text, table_format = TextTableFormat(borders = text_table_borders__mysql) )
+--------+--------+--------+--------+ | Col. 1 | Col. 2 | Col. 3 | Col. 4 | +--------+--------+--------+--------+ | 1 | false | 1.0 | 1 | | 2 | true | 2.0 | 2 | | 3 | false | 3.0 | 3 | +--------+--------+--------+--------+
text_table_borders__simple
julia> pretty_table( data; backend = :text, table_format = TextTableFormat(borders = text_table_borders__simple) )
========= ======== ======== ========= Col. 1 Col. 2 Col. 3 Col. 4 ========= ======== ======== ========= 1 false 1.0 1 2 true 2.0 2 3 false 3.0 3 ========= ======== ======== =========
text_table_borders__unicode_rounded
julia> pretty_table( data; backend = :text, table_format = TextTableFormat(borders = text_table_borders__unicode_rounded) )
╭────────┬────────┬────────┬────────╮ │ Col. 1 │ Col. 2 │ Col. 3 │ Col. 4 │ ├────────┼────────┼────────┼────────┤ │ 1 │ false │ 1.0 │ 1 │ │ 2 │ true │ 2.0 │ 2 │ │ 3 │ false │ 3.0 │ 3 │ ╰────────┴────────┴────────┴────────╯
Formats
The text backend also defined some pre-defined formats to print the tables that can be used through the keyword table_format
in pretty_table
.
text_table_format__matrix
julia> pretty_table( ones(3, 3); backend = :text, show_column_labels = false, table_format = text_table_format__matrix )
┌ ┐ │ 1.0 1.0 1.0 │ │ 1.0 1.0 1.0 │ │ 1.0 1.0 1.0 │ └ ┘