GitHub user agoodm opened a pull request:

    https://github.com/apache/zeppelin/pull/1329

    ZEPPELIN-1318 - Add support for png images in z.show()

    ### What is this PR for?
    This PR adds support for plotting png images using the matplotlib helper 
function within a python interpreter (eg `z.show()`). The primary motivation 
for this is due to the overhead incurred from svg images, which can lag the 
notebooks if multiple, complicated images are generated (for example, multiple 
filled contour plots). png images are more lightweight, but of course come at a 
cost of image quality due to them being raster rather than vector like svg. The 
support for png images is incorporated through the use of a new optional 
argument to `z.show` called `fmt` which can be one of `'svg'` or `'png'`. The 
same code that is currently used in show is used for svg images while the code 
for png images relies on converting the image directly to a byte array and then 
entering the decoded byte string directly into an HTML image tag. Currently 
`fmt` defaults to `'png'` but I think we should consider discussing the pros 
and cons of each option in this PR. 
    
    ### What type of PR is it?
    Improvement
    
    ### What is the Jira issue?
    [ZEPPELIN-1318](https://issues.apache.org/jira/browse/ZEPPELIN-1318)
    
    ### How should this be tested?
    In a notebook cell, enter:
    ```python
    %python
    import matplotlib.pyplot as plt
    import numpy as np
    
    plt.figure()
    plt.plot(np.arange(10))
    z.show(plt, fmt=fmt)
    ```
    Where `fmt` may be one of `'svg'` or `'png'`, and any other input should 
result in a `ValueError`. I would also recommend testing the example in the 
screenshot below. 
    
    ### Screenshots (if appropriate)
    ![zeppelin plot](https://puu.sh/qzc4t/b8fcfe856e.png)
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? Yes (if the changes to the `help()` 
docstring are not sufficient)
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/agoodm/zeppelin ZEPPELIN-1318

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/zeppelin/pull/1329.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1329
    
----
commit 1efa0c975e41aa3c8b95d0f5e084619d8e996582
Author: Alex Goodman <ago...@users.noreply.github.com>
Date:   2016-08-12T21:31:40Z

    ZEPPELIN-1318 - Add support for png images in z.show()

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to