I want to plot a bar graph in elixir and save it as an image.
Is there any good charting library for doing this ?
I tried searching on elixir.libhunt.com and github.com/h4cc/awesome-elixir, but didn't find a single package for my need.
Thanks in advance.
Yes - you can interface to gnuplot with gnuplot-elixir
As as example, to generate the bar graph in this answer - the code would be:
import Gnuplot
chart = [
[:set, :term, :png, :size, '512,512'],
[:set, :output, Path.join("/tmp", "barchart.PNG")],
[:set, :boxwidth, 0.5],
~w(set style fill solid)a,
[:plot, "-", :using, '1:3:xtic(2)', :with, :boxes]
]
dataset = [[0, "label", 100], [1, "label2", 450], [2, "bar label", 75]]
plot(chart, [dataset])
I don't think there's any such control for Elixir--nothing native anyway. Graphics is not exactly in Elixir's wheelhouse. However, I think you could probably build something yourself with wxErlang. You can see what sorts of things you can do with wxErlang in Elixir by typing :wx.demo()
from within iex. I don't know of a graph primitive in wxErlang but it may be that I simply haven't found it yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With