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