web2.py + mpld3: how to display the generated HTML

324 views
Skip to first unread message

Stavros Anastasiadis

unread,
Aug 20, 2014, 6:19:54 AM8/20/14
to web...@googlegroups.com
I am trying to use mpld3 (http://mpld3.github.io/index.html) to generate an example plot with web2py.

so far in my simple example:

controller:

def example_plot():
     import matplotlib.pyplot as plt, mpld3
     fig, ax = plt.subplots()
     plot = ax.plot([3,1,4,1,5], 'ks-', mec='w', mew=5, ms=20)
     make_html = mpld3.fig_to_html(fig, template_type = "general")
     return locals()

view:

{{=HTML(make_html)}}


The code passed the generated html to my view but i get raw html. 
How i actually can render  the make_html to a view?  
Any suggestions ?  



Anthony

unread,
Aug 20, 2014, 2:21:34 PM8/20/14
to web...@googlegroups.com
{{=XML(make_html)}}

Anthony

Ruud Schroen

unread,
Aug 21, 2014, 11:08:20 AM8/21/14
to
Or return XML(make_html), whatever you find easier.


Reply all
Reply to author
Forward
0 new messages