Alex Goodman created ZEPPELIN-1318:
--------------------------------------

             Summary: Add support for png images in z.show()
                 Key: ZEPPELIN-1318
                 URL: https://issues.apache.org/jira/browse/ZEPPELIN-1318
             Project: Zeppelin
          Issue Type: Improvement
          Components: python-interpreter
    Affects Versions: 0.7.0
            Reporter: Alex Goodman
             Fix For: 0.7.0


The current implementation of {{z.show()}} supports matplotlib plotting svg 
images inline. However with some type of plots in matplotlib, particularly for 
maps via basemap, this causes the UI in the notebook to severely lag when the 
output isn't hidden. Saving the images in .png format solves this problem, but 
a different implementation is required in order to plot the image inline. I 
have proposed a solution below where the image is saved into a byte array and 
then displayed directly via html:

{code}
import cStringIO
import base64
def show(p):
    img = cStringIO.StringIO()
    p.savefig(img, format='png')
    imgStr = "data:image/png;base64,"
    imgStr += base64.b64encode(img.getvalue().strip())
    print "%html <img src='" + imgStr + "'>" 
{code}

I will incorporate this into zeppelin's {{z.show()}} function. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to