Re: Is it possible to output a graph from Matplotlib into Django like this?

2016-05-21 Thread Yunpeng Pan
This solution makes a lot of sense! On Tuesday, April 12, 2011 at 1:06:55 AM UTC-5, Sam Walters wrote: > > I mis-read this... basically you have one view and in the template you > are rendering you put HTML: > > > > > > so that path will call your other views which return content as > content_ty

Re: Is it possible to output a graph from Matplotlib into Django like this?

2011-04-14 Thread Derek
On Apr 14, 5:48 am, nai wrote: > Thanks for your help. > > I went with 2 views, 1 for the image and 1 for the html. > > On Apr 12, 2:06 pm, Sam Walters wrote: > > I mis-read this... basically you have one view and in the template you > > are rendering you put HTML: > > > > > > > > so that path

Re: Is it possible to output a graph from Matplotlib into Django like this?

2011-04-13 Thread nai
Thanks for your help. I went with 2 views, 1 for the image and 1 for the html. On Apr 12, 2:06 pm, Sam Walters wrote: > I mis-read this... basically you have one view and in the template you > are rendering you put HTML: > > > > > so that path will call your other views which return content as

Re: Is it possible to output a graph from Matplotlib into Django like this?

2011-04-12 Thread Aryeh Leib Taurog
On Apr 11, 1:21 pm, nai wrote: > Is there anyway I can return the image like this `return > render_to_response('template.html', {'graph': matplotlib or some other graphing package>}` As noted, images are almost always loaded independently. See, for example, "Definition and Usage" of img tag her

Re: Is it possible to output a graph from Matplotlib into Django like this?

2011-04-11 Thread Sam Walters
I mis-read this... basically you have one view and in the template you are rendering you put HTML: so that path will call your other views which return content as content_type='image/png' or whatever specific format you're using. what i was suggesting is you could have: So in your urls.p

Re: Is it possible to output a graph from Matplotlib into Django like this?

2011-04-11 Thread Sam Walters
Hi How about one view that takes arguments as either POST or GET params? > You have to bear with me but where does background come from? So I can > use the save() method from the PIL library is that right? Ok so you can load a canvas. Just to illustrate here is a view that puts dots on a map *m

Re: Is it possible to output a graph from Matplotlib into Django like this?

2011-04-11 Thread nai
You have to bear with me but where does background come from? So I can use the save() method from the PIL library is that right? And I can do something like this: return render_to_response('template.html', {'graph':response}) Where graph is just a variable in my django template (and not ) Is th

Re: Is it possible to output a graph from Matplotlib into Django like this?

2011-04-11 Thread nai
Actually, could you illustrate how you would go about using 2 views as well? Thanks! On Apr 11, 6:39 pm, Xavier Ordoquy wrote: > Le 11 avr. 2011 à 12:21, nai a écrit : > > > > > > > > > > > This is the give example from Matplotlib for Django: > > > def simple(request): > >    import random > > >

Re: Is it possible to output a graph from Matplotlib into Django like this?

2011-04-11 Thread Sam Walters
Use python imaging: http://www.pythonware.com/products/pil/ You can return a response with an image of the graph. response = HttpResponse(status=200, mimetype="image/gif") background.save(response, "GIF") return response There is no 'best practice for this' Some people i know use flash. However

Re: Is it possible to output a graph from Matplotlib into Django like this?

2011-04-11 Thread nai
One reason why I don't quite like the idea is because I am writing a reporting webapp and there are many different graphs that can generated. Needing to write 2 views for 1 type of graph can get pretty tedious! On Apr 11, 6:39 pm, Xavier Ordoquy wrote: > Le 11 avr. 2011 à 12:21, nai a écrit : > >

Re: Is it possible to output a graph from Matplotlib into Django like this?

2011-04-11 Thread nai
I will try to the 2 views method and see how I get on but in it would be great if you could answer my questions too! Why does it go against best practices? How would one go about doing it anyway? On Apr 11, 6:39 pm, Xavier Ordoquy wrote: > Le 11 avr. 2011 à 12:21, nai a écrit : > > > > > > >

Re: Is it possible to output a graph from Matplotlib into Django like this?

2011-04-11 Thread Derek
On Apr 11, 12:39 pm, Xavier Ordoquy wrote: > Le 11 avr. 2011 à 12:21, nai a écrit :> > > > This is the give example from Matplotlib for Django: > > > def simple(request): > >    import random > > >    from matplotlib.backends.backend_agg import FigureCanvasAgg as > > FigureCanvas > >    from matp

Re: Is it possible to output a graph from Matplotlib into Django like this?

2011-04-11 Thread Xavier Ordoquy
Le 11 avr. 2011 à 12:21, nai a écrit : > This is the give example from Matplotlib for Django: > > def simple(request): >import random > >from matplotlib.backends.backend_agg import FigureCanvasAgg as > FigureCanvas >from matplotlib.figure import Figure >from matplotlib.dates imp

Is it possible to output a graph from Matplotlib into Django like this?

2011-04-11 Thread nai
This is the give example from Matplotlib for Django: def simple(request): import random from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure from matplotlib.dates import DateFormatter fig=Figure() ax=fig.add_subp