On Fri, Jan 11, 2013 at 6:14 AM, Navid Shaikh <shaikhnavi...@gmail.com>wrote:

> Hi  all,
>
> I am using matplotlib with Django.
> I want to display figures processed in Django apps by matplotlib in
> browser using html5.
>
> I tried:
>
> *def plot_file(request):*
> *    import matplotlib.cbook as cbook*
> *    fig = figure()*
> *    fname = cbook.get_sample_data('msft.csv', asfileobj=False)*
> *    plotfile(fname, (0,1,2,3))*
> *
> *
> *    canvas = FigureCanvas(fig)*
> *    response = HttpResponse(content_type="image/png")*
> *    canvas.print_png(response)*
> *    fig.clear()*
> *    return response*
>
> This response takes whole page and displays figure.
> I have other contents as well to display along with figure.
>
> How can I send it as a canvas object or something else(I am unaware of) in
> order to have print logic in html file(django templates)
> in order to position figure as my requirement:
>
> I thought of something like this, but not sure:
>
> *def plot_file(request):*
> *    ---------------*
> *    ---------------*
> *    return render_to_response('template.html',{*
> *        'canvas':canvas,*
> *    },  *
> *    context_instance=RequestContext(request),*
> *    )   *
>
> -------------------------------------------------------------------------------------------------------------------------
> Please make me inform, If I need to provide more context.
>
> Regards,
> Navid Shaikh.
>
>
We have fairly recently merged in a WebAgg backend that makes it possible
for matplotlib to serve out an interactive figure window, using html5.
This is currently in the master branch and has not been released yet.
Don't know how well it would work within Django, but might be worth
investigating.

https://github.com/matplotlib/matplotlib/pull/1426

Ben Root
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to