Skip to content

Commit 3a8b8d9

Browse files
committed
Bar chart with labels example from SO 327576
1 parent e0cf5bf commit 3a8b8d9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

examples/so327576.exs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
defmodule BarChart do
2+
import Gnuplot
3+
4+
@moduledoc "Chart from https://stackoverflow.com/a/11551808/3366"
5+
6+
def run do
7+
8+
chart = [
9+
[:set, :term, :png, :size, '512,512'],
10+
[:set, :output, Path.join("/tmp", "barchart.PNG")],
11+
[:set, :boxwidth, 0.5],
12+
~w(set style fill solid)a,
13+
[:plot, "-", :using, '1:3:xtic(2)', :with, :boxes]
14+
]
15+
16+
dataset = [[0, "label", 100], [1, "label2", 450], [2, "bar_label", 75]]
17+
18+
plot(chart, [dataset])
19+
end
20+
end
21+
22+
# mix run examples/so327576.exs
23+
BarChart.run()

0 commit comments

Comments
 (0)