Uploaded image for project: 'Zeppelin'
  1. Zeppelin
  2. ZEPPELIN-1318

Add support for matplotlib displaying png images in python interpreter

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.6.1, 0.7.0
    • 0.7.0
    • python-interpreter
    • None

    Description

      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:

      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 + "'>" 
      

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

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            agoodman Alex Goodman
            agoodman Alex Goodman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment