Skip to content

Commit 1bed7b7

Browse files
committed
Fix integer-valued reference plot labels
1 parent 312f8c8 commit 1bed7b7

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

spec/reference/barplot_spec.cr

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@ require "../support/reference_helpers"
33
describe "Julia reference output compatibility - barplot" do
44
describe "barplot" do
55
it "matches barplot/default" do
6-
p = UnicodePlot.barplot(["bar", "foo"], [23.0, 37.0])
6+
p = UnicodePlot.barplot(["bar", "foo"], [23, 37])
77
test_ref("barplot/default.txt", p)
88
end
99

1010
it "matches barplot/default2 (with barplot! appended)" do
11-
p = UnicodePlot.barplot(["bar", "foo"], [23.0, 37.0])
12-
UnicodePlot.barplot!(p, ["zoom"], [90.0])
11+
p = UnicodePlot.barplot(["bar", "foo"], [23, 37])
12+
UnicodePlot.barplot!(p, ["zoom"], [90])
1313
test_ref("barplot/default2.txt", p)
1414
end
1515

1616
it "matches barplot/nocolor" do
17-
p = UnicodePlot.barplot(["bar", "foo"], [23.0, 37.0])
17+
p = UnicodePlot.barplot(["bar", "foo"], [23, 37])
1818
test_ref("barplot/nocolor.txt", p)
1919
end
2020

2121
it "matches barplot/ranges" do
22-
p = UnicodePlot.barplot(["2", "3", "4", "5", "6"], [11.0, 12.0, 13.0, 14.0, 15.0])
22+
p = UnicodePlot.barplot(["2", "3", "4", "5", "6"], [11, 12, 13, 14, 15])
2323
test_ref("barplot/ranges.txt", p)
2424
end
2525

2626
it "matches barplot/ranges2" do
27-
p = UnicodePlot.barplot(["2", "3", "4", "5", "6"], [11.0, 12.0, 13.0, 14.0, 15.0])
28-
UnicodePlot.barplot!(p, ["9", "10"], [20.0, 21.0])
27+
p = UnicodePlot.barplot(["2", "3", "4", "5", "6"], [11, 12, 13, 14, 15])
28+
UnicodePlot.barplot!(p, ["9", "10"], [20, 21])
2929
test_ref("barplot/ranges2.txt", p)
3030
end
3131

@@ -71,24 +71,24 @@ describe "Julia reference output compatibility - barplot" do
7171
end
7272

7373
it "matches barplot/edgecase_zeros" do
74-
p = UnicodePlot.barplot(["5", "4", "3", "2", "1"], [0.0, 0.0, 0.0, 0.0, 0.0])
74+
p = UnicodePlot.barplot(["5", "4", "3", "2", "1"], [0, 0, 0, 0, 0])
7575
test_ref("barplot/edgecase_zeros.txt", p)
7676
end
7777

7878
it "matches barplot/edgecase_onelarge" do
79-
p = UnicodePlot.barplot(["a", "b", "c", "d"], [1.0, 1.0, 1.0, 1_000_000.0])
79+
p = UnicodePlot.barplot(["a", "b", "c", "d"], [1, 1, 1, 1_000_000])
8080
test_ref("barplot/edgecase_onelarge.txt", p)
8181
end
8282

8383
it "matches barplot/col1 (8-bit terminal color, ANSI stripped)" do
84-
p = UnicodePlot.barplot(["B", "A"], [2.0, 1.0], color: 9_i32)
84+
p = UnicodePlot.barplot(["B", "A"], [2, 1], color: 9_i32)
8585
test_ref("barplot/col1.txt", p)
8686
end
8787

8888
it "matches barplot/log10" do
8989
p = UnicodePlot.barplot(
9090
["a", "b", "c", "d", "e"],
91-
[0.0, 1.0, 10.0, 100.0, 1_000.0],
91+
[0, 1, 10, 100, 1_000],
9292
title: "Logscale Plot",
9393
xscale: :log10,
9494
)
@@ -98,7 +98,7 @@ describe "Julia reference output compatibility - barplot" do
9898
it "matches barplot/log10_label" do
9999
p = UnicodePlot.barplot(
100100
["a", "b", "c", "d", "e"],
101-
[0.0, 1.0, 10.0, 100.0, 1_000.0],
101+
[0, 1, 10, 100, 1_000],
102102
title: "Logscale Plot",
103103
xlabel: "custom label",
104104
xscale: :log10,
@@ -107,14 +107,14 @@ describe "Julia reference output compatibility - barplot" do
107107
end
108108

109109
it "matches barplot/col2 (RGB tuple color)" do
110-
p = UnicodePlot.barplot(["B", "A"], [2.0, 1.0], color: {200, 50, 0})
110+
p = UnicodePlot.barplot(["B", "A"], [2, 1], color: {200, 50, 0})
111111
test_ref("barplot/col2.txt", p)
112112
end
113113

114114
it "matches barplot/colors (per-bar color vector)" do
115115
p = UnicodePlot.barplot(
116116
["a", "b", "c", "d", "e"],
117-
[20.0, 30.0, 60.0, 50.0, 40.0],
117+
[20, 30, 60, 50, 40],
118118
color: [:red, :green, :blue, :yellow, :normal],
119119
)
120120
test_ref("barplot/colors.txt", p)
@@ -123,7 +123,7 @@ describe "Julia reference output compatibility - barplot" do
123123
it "matches barplot/maximum_series1" do
124124
p = UnicodePlot.barplot(
125125
["1", "2", "3"],
126-
[1.0, 2.0, 3.0],
126+
[1, 2, 3],
127127
color: :blue,
128128
name: "1ˢᵗ series",
129129
maximum: 10.0,
@@ -134,12 +134,12 @@ describe "Julia reference output compatibility - barplot" do
134134
it "matches barplot/maximum_series2" do
135135
p = UnicodePlot.barplot(
136136
["1", "2", "3"],
137-
[1.0, 2.0, 3.0],
137+
[1, 2, 3],
138138
color: :blue,
139139
name: "1ˢᵗ series",
140140
maximum: 10.0,
141141
)
142-
UnicodePlot.barplot!(p, ["4", "5", "6"], [6.0, 1.0, 10.0], color: :red, name: "2ⁿᵈ series")
142+
UnicodePlot.barplot!(p, ["4", "5", "6"], [6, 1, 10], color: :red, name: "2ⁿᵈ series")
143143
test_ref("barplot/maximum_series2.txt", p)
144144
end
145145
end

src/unicode_plot/interface/histogram.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ module UnicodePlot
300300
border: border, margin: margin, padding: padding,
301301
labels: labels, unicode_exponent: unicode_exponent,
302302
thousands_separator: thousands_separator, symbols: symbols,
303-
width: width
303+
width: width, integer_labels: true
304304
)
305305
plot
306306
end

0 commit comments

Comments
 (0)