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; backend = :html)
Col. 1 |
Col. 2 |
Col. 3 |
Col. 4 |
1 |
false |
1.0 |
1 |
2 |
true |
2.0 |
2 |
3 |
false |
3.0 |
3 |
4 |
true |
4.0 |
4 |
5 |
false |
5.0 |
5 |
6 |
true |
6.0 |
6 |
julia> pretty_table(
A;
backend = :html,
style = HtmlTableStyle(;
first_line_column_label = ["color" => "BurlyWood", "font-weight" => "bold"]
)
)
Col. 1 |
Col. 2 |
Col. 3 |
Col. 4 |
1 |
false |
1.0 |
1 |
2 |
true |
2.0 |
2 |
3 |
false |
3.0 |
3 |
4 |
true |
4.0 |
4 |
5 |
false |
5.0 |
5 |
6 |
true |
6.0 |
6 |
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;
backend = :html,
column_labels,
merge_column_label_cells = :auto,
row_labels,
stubhead_label = "Effect",
style = HtmlTableStyle(;
first_line_merged_column_label = ["color" => "BurlyWood", "font-weight" => "bold"],
column_label = ["color" => "DarkGrey"],
stubhead_label = ["color" => "BurlyWood", "font-weight" => "bold"],
summary_row_label = ["color" => "red", "font-weight" => "bold"]
),
summary_row_labels = ["Total"],
summary_rows = [(data, i) -> sum(data[:, i])],
)
Effect |
Value |
|
Torque [10⁻⁶ Nm] |
Angular Momentum [10⁻³ Nms] |
Atmospheric drag |
10.0 |
6.5 |
Gravity gradient |
3.0 |
3.0 |
Solar radiation pressure |
0.1 |
1.0 |
Total |
13.1 |
10.5 |
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 = HtmlHighlighter(
(data, i, j) -> (j == 4) && (data[i, j] > 9),
["color" => "blue"]
)
julia> hl_v = TextHighlighter(
(data, i, j) -> (j == 3) && (data[i, j] > 9),
["color" => "red"]
)
julia> pretty_table(
data;
backend = :html,
column_labels = column_labels,
highlighters = [hl_p, hl_v],
style = HtmlTableStyle(;
first_line_column_label = ["color" => "BurlyWood", "font-weight" => "bold"],
column_label = ["color" => "DarkGrey"],
)
)
Time |
Acceleration |
Velocity |
Distance |
[s] |
[m / s²] |
[m / s] |
[m] |
0.0 |
1.0 |
0.0 |
0.0 |
1.0 |
1.0 |
1.0 |
0.5 |
2.0 |
1.0 |
2.0 |
2.0 |
3.0 |
1.0 |
3.0 |
4.5 |
4.0 |
1.0 |
4.0 |
8.0 |
5.0 |
1.0 |
5.0 |
12.5 |
6.0 |
1.0 |
6.0 |
18.0 |
7.0 |
1.0 |
7.0 |
24.5 |
8.0 |
1.0 |
8.0 |
32.0 |
9.0 |
1.0 |
9.0 |
40.5 |
10.0 |
1.0 |
10.0 |
50.0 |
11.0 |
1.0 |
11.0 |
60.5 |
12.0 |
1.0 |
12.0 |
72.0 |
13.0 |
1.0 |
13.0 |
84.5 |
14.0 |
1.0 |
14.0 |
98.0 |
15.0 |
1.0 |
15.0 |
112.5 |
16.0 |
1.0 |
16.0 |
128.0 |
17.0 |
1.0 |
17.0 |
144.5 |
18.0 |
1.0 |
18.0 |
162.0 |
19.0 |
1.0 |
19.0 |
180.5 |
20.0 |
1.0 |
20.0 |
200.0 |