Documentation help request for web frameworks

Folks,

I know that there is a use of mpl as part of django / flask / bottle / zope
/ ... to write figures directly to buffers and serve them to users without
writing to disk (an example of this is
http://scipy-cookbook.readthedocs.io/items/Matplotlib_Django.html , but I
think this is better done via `fig.savefig(bytes_io_buffer, format='png')`
rather than reaching in and touching the canvas directly).

This seems like the sort of thing that should be easy to find in our
documentation. Is anyone interested in writing up 'canonical' examples?

Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160905/d00bc7d6/attachment.html>

I don't have the time to do a decent writeup of this, but here is a
function that I use that does the byteio thing automatically. Perhaps it
will be useful to someone who is willing to do the writeup. I trimmed out
the domain-specific parts and left only the interesting bits:

def saveFigure(fig, file=None, **kwargs):
    """
    Saves the figure as an image using `matplotlib.pyplot.savefig`.

    The main value of this method is that it automatically saves to memory
via
    a `BytesIO` object if a file is not specified.

    fig: The figure to save
    file: Either a file name or file-like object, or `None`. In the former
two
        cases, there is no return value. In the latter case, a `BytesIO`
        containing the image will be returned. The output will be rewound to
        the start in that case. The default is `None`.

    All other arguments are passed through directly to `savefig`. `format`
defaults
    to 'png' if unset. Some common options include:
    """
    output = BytesIO() if file is None else file
    kwargs.setdefault('format', 'png')
    fig.savefig(output, **kwargs)
    if file is None:
        output.seek(0)
    return output
···

On Mon, Sep 5, 2016 at 2:28 PM, Thomas Caswell <tcaswell at gmail.com> wrote:

Folks,

I know that there is a use of mpl as part of django / flask / bottle /
zope / ... to write figures directly to buffers and serve them to users
without writing to disk (an example of this is http://scipy-cookbook.
readthedocs.io/items/Matplotlib_Django.html , but I think this is better
done via `fig.savefig(bytes_io_buffer, format='png')` rather than reaching
in and touching the canvas directly).

This seems like the sort of thing that should be easy to find in our
documentation. Is anyone interested in writing up 'canonical' examples?

Tom

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160906/8b8e16c5/attachment.html>

Hi:

I have a third party tool that allows me to create still frame ?.png? images (about 30-frames) ) from an ?.mpv? movie. I now need to read this series of 30 or so still frames into my IPython -based image processing environment automatically after being directed to the right source folder. Has someone already done something like this? I can currently read single frame images one at a time.

I am not sure is if this is the right group to be posing the question to. If not I apologize and would appreciate being pointed to the right one.

Thanks.

Dipu

Dipankar Ganguly
Consultant: Strategy/Technology/Commercialization
Bothell, WA
Cell: 408-203-8814
email: dipugee at gmail.com
http://www.linkedin.com/in/dipugee

···

On Sep 6, 2016, at 8:26 AM, Joseph Fox-Rabinovitz <jfoxrabinovitz at gmail.com> wrote:

I don't have the time to do a decent writeup of this, but here is a function that I use that does the byteio thing automatically. Perhaps it will be useful to someone who is willing to do the writeup. I trimmed out the domain-specific parts and left only the interesting bits:

def saveFigure(fig, file=None, **kwargs):
    """
    Saves the figure as an image using `matplotlib.pyplot.savefig`.

    The main value of this method is that it automatically saves to memory via
    a `BytesIO` object if a file is not specified.

    fig: The figure to save
    file: Either a file name or file-like object, or `None`. In the former two
        cases, there is no return value. In the latter case, a `BytesIO`
        containing the image will be returned. The output will be rewound to
        the start in that case. The default is `None`.

    All other arguments are passed through directly to `savefig`. `format` defaults
    to 'png' if unset. Some common options include:
    """
    output = BytesIO() if file is None else file
    kwargs.setdefault('format', 'png')
    fig.savefig(output, **kwargs)
    if file is None:
        output.seek(0)
    return output

On Mon, Sep 5, 2016 at 2:28 PM, Thomas Caswell <tcaswell at gmail.com <mailto:tcaswell at gmail.com>> wrote:
Folks,

I know that there is a use of mpl as part of django / flask / bottle / zope / ... to write figures directly to buffers and serve them to users without writing to disk (an example of this is http://scipy-cookbook.readthedocs.io/items/Matplotlib_Django.html , but I think this is better done via `fig.savefig(bytes_io_buffer, format='png')` rather than reaching in and touching the canvas directly).

This seems like the sort of thing that should be easy to find in our documentation. Is anyone interested in writing up 'canonical' examples?

Tom

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org <mailto:Matplotlib-users at python.org>
https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
https://mail.python.org/mailman/listinfo/matplotlib-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160906/15d16849/attachment-0001.html>