[PYTHON] convert ggplot based graph to html

ggplot based graph can be converted to html using mpld3.fig_to_html. The point is to call draw method to generate matplotlib figure object, though it is not mentioned in ggplot manual now. The html piece can be used in templates.

import matplotlib.pyplot as plt, mpld3
from ggplot import *

ggp = ggplot(aes(x='date', y='beef'), data=meat) +\
      geom_line() +\
      stat_smooth(colour='blue', span=0.2)
fig = ggp.draw()
html = mpld3.fig_to_html(fig)

Recommended Posts

convert ggplot based graph to html
Convert HTML to text file
Convert .ipynb to .html (with BatchFile)
Convert from Markdown to HTML in Python
Convert to HSV
Convert 202003 to 2020-03 with pandas
Convert kanji to kana
Convert jupyter to py
Convert keras-yolo3 to onnx
Convert dict to array
Convert json to excel
Convert hexadecimal string to binary
[python] Convert date to string
Convert numpy int64 to python int
[Python] Convert list to Pandas [Pandas]
Convert Scratch project to Python
[Python] Convert Shift_JIS to UTF-8
Convert IP address to decimal
Convert SDF to CSV quickly
Convert genbank file to gff file
Convert python 3.x code to python 2.x
Download Google logo → Convert to text with OCR → Display on HTML