LoginSignup
1

More than 5 years have passed since last update.

convert ggplot based graph to html

Posted at

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)

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1