PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/examples/d3py_bar.py

https://github.com/followyourheart/d3py
Python | 28 lines | 18 code | 5 blank | 5 comment | 1 complexity | b06eac2466646456ec38c91cd752444e MD5 | raw file
  1. import pandas
  2. import d3py
  3. import logging
  4. logging.basicConfig(level=logging.DEBUG)
  5. df = pandas.DataFrame(
  6. {
  7. "count" : [1,4,7,3,2,9],
  8. "apple_type": ["a", "b", "c", "d", "e", "f"],
  9. }
  10. )
  11. # use 'with' if you are writing a script and want to serve this up forever
  12. with d3py.PandasFigure(df) as p:
  13. p += d3py.Bar(x = "apple_type", y = "count", fill = "MediumAquamarine")
  14. p += d3py.xAxis(x = "apple_type")
  15. p.show()
  16. # if you are writing in a terminal, use without 'with' to keep everything nice
  17. # and interactive
  18. """
  19. p = d3py.PandasFigure(df)
  20. p += d3py.Bar(x = "apple_type", y = "count", fill = "MediumAquamarine")
  21. p += d3py.xAxis(x = "apple_type")
  22. p.show()
  23. """