libraries_support.rst 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. Libraries support
  2. ======================
  3. .. _visualization:
  4. Data visualization
  5. --------------------
  6. PyWebIO supports for data visualization with the third-party libraries.
  7. Bokeh
  8. ^^^^^^^^^^^^^^^^^^^^^^
  9. `Bokeh <https://github.com/bokeh/bokeh>`_ is an interactive visualization library for modern web browsers. It provides elegant, concise construction of versatile graphics, and affords high-performance interactivity over large or streaming datasets.
  10. You can use ``bokeh.io.output_notebook(notebook_type='pywebio')`` in the PyWebIO session to setup Bokeh environment.
  11. Then you can use ``bokeh.io.show()`` to output a boken chart::
  12. from bokeh.io import output_notebook
  13. from bokeh.io import show
  14. output_notebook(notebook_type='pywebio')
  15. fig = figure(...)
  16. ...
  17. show(fig)
  18. See related demo on :charts_demo_host:`bokeh demo </?app=bokeh>`
  19. In addition to creating ordinary charts, Bokeh can also build the Bokeh applications by starting the `Bokeh server <https://docs.bokeh.org/en/latest/docs/user_guide/server.html>`_. The purpose of the Bokeh server is to make it easy for Python users to create interactive web applications that can connect front-end UI events to real, running Python code.
  20. In PyWebIO, you can also use ``bokeh.io.show()`` to display a Bokeh App. For the example, see `bokeh_app.py <https://github.com/wang0618/PyWebIO/blob/dev/demos/bokeh_app.py>`_.
  21. .. note:: Bokeh App currently is only available in the default Tornado backend
  22. .. image:: https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery@master/assets/bokeh.png
  23. pyecharts
  24. ^^^^^^^^^^^^^^^^^^^^^^
  25. `pyecharts <https://github.com/pyecharts/pyecharts>`_ is a python plotting library which uses `Echarts <https://github.com/ecomfe/echarts>`_ as underlying implementation.
  26. In PyWebIO, you can use the following code to output the pyecharts chart instance::
  27. # `chart` is pyecharts chart instance
  28. pywebio.output.put_html(chart.render_notebook())
  29. See related demo on :charts_demo_host:`pyecharts demo </?app=pyecharts>`
  30. .. only:: not latex
  31. .. image:: https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery@master/assets/pyecharts.gif
  32. plotly
  33. ^^^^^^^^^^^^^^^^^^^^^^
  34. `plotly.py <https://github.com/plotly/plotly.py>`_ is an interactive, open-source, and browser-based graphing library for Python.
  35. In PyWebIO, you can use the following code to output the plotly chart instance::
  36. # `fig` is plotly chart instance
  37. html = fig.to_html(include_plotlyjs="require", full_html=False)
  38. pywebio.output.put_html(html)
  39. See related demo on :charts_demo_host:`plotly demo </?app=plotly>`
  40. .. image:: https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery@master/assets/plotly.png
  41. cutecharts.py
  42. ^^^^^^^^^^^^^^^^^^^^^^
  43. `cutecharts.py <https://github.com/cutecharts/cutecharts.py>`_ is a hand drawing style charts library for Python which uses `chart.xkcd <https://github.com/timqian/chart.xkcd>`_ as underlying implementation.
  44. In PyWebIO, you can use the following code to output the cutecharts.py chart instance::
  45. # `chart` is cutecharts chart instance
  46. pywebio.output.put_html(chart.render_notebook())
  47. See related demo on :charts_demo_host:`cutecharts demo </?app=cutecharts>`
  48. .. image:: https://cdn.jsdelivr.net/gh/wang0618/pywebio-chart-gallery@master/assets/cutecharts.png