Re: Matplotlib with Django

2010-02-01 Thread jarraneil
Did you ever figure out how to do this? I am stuck with exactly the
same problem that you first described i.e. how to allow the user to
control the chart they are presented with. In my case I want to give
them the ability to zoom, pan and select visible traces

On Dec 26 2009, 12:27 pm, heaviside x  wrote:
> I have looked at POST via AJAX, but I started to steer away from it
> after I read that a POST request is more for changing or updating data
> in a database and GET is more for changing how the data is viewed.  Is
> my understanding wrong?  Honestly, I am a python programmer who is
> picking up web development as I go.
>
> In addition, I've been trying to implement this so it works without
> javascript if necessary (I've read that this is the best practice if
> possible).  If I were to implement this w/out javascript with POST
> wouldn't I need to pass all the parameters via the URL?
>
> How does youtube shorten their URLs?
>
> Finally,  the code snippet your proposed would work, but what I was
> trying to do by returning both an image and HTML in a request is
> remove the separation between my two views.
>
> On Dec 26, 5:39 am, Hinnack  wrote:
>
> > if you want to offer lots of properties one can change, POST via ajax is the
> > better way - as you said
> > long URLs can get very ugly - although you could shorten them like youtube
> > or others do it.
> > GET is far better at this point of time, as only GET requests are cachable
> > (as far as I know) by djangos
> > middleware.
>
> > if I understand you right: you want to mix html with image-data? That is
> > impossible. But you can
> > add parameters to the header of the http response of the image and put in
> > there all settings needed to render the image...
> > So you need 2 urls - although you could add a second variable to the url
> > e.g. output:
> > url(r'^graph_example/(?P\d+)/(?P\w+)/$')
>
> > and then a view:
>
> > def myview(request, id, output):
> >    if output == 'image':
> >      # output image data
> >    else:
> >       # output html data
>
> > 2009/12/26 heaviside x 
>
> > > Hello,
>
> > > To start, this is not another how do I getmatplotlibto work in
> > > Django thread.  This is how do I getmatplotlibto work better with
> > > django.  Before I go on, let me outline what I'm doing.
>
> > > I'm currently working on a scientific data manager/viewer which uses
> > >matplotlibas the primary graphing workhorse.  My intention is to be
> > > able to easily handle all sorts of crazy scientific plots (Smith
> > > Charts, Polar Plots with negative values, and other crazy mappings).
> > > In the past,matplotlibhas been able to easily and elegantly handle
> > > these charts, so I'm sticking with it for now.  I also want to be able
> > > to take these generated plots and quickly dump them into documents or
> > > reports so a save functionality (or drag and drop via the browser) is
> > > key.
>
> > > Currently, my application is based off the standardmatplotlib
> > > example.  I have a webpage that contains a static graph.png image and
> > > I point that url to another view that renders mymatplotlibpng and
> > > returns it.
>
> > > url(r'^graph_example/(?P\d+)/$')
> > > url(r'^graph_example/(?P\d+)/graph.png')
>
> > > How should I implement editable scales, titles, and labels?  For
> > > instance, the graph comes up but I want a different scaling for a
> > > report.  I could add all this information as url variables to the
> > > view, but that would be extremely ugly.  Is the simple solution a
> > > query string?  However, this also yields very ugly URLs.
>
> > > Instead of just returning an image in the HttpResposne as the django/
> > >matplotlibexample shows, is there a way to return the image with the
> > > rest of the base page's response?  Removing the need for hard coding a
> > > "graph.png" url into my template.
>
> > > Any help would be greatly appreciated.
>
> > > --
>
> > > You received this message because you are subscribed to the Google Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Matplotlib with Django

2009-12-26 Thread heaviside x
I have looked at POST via AJAX, but I started to steer away from it
after I read that a POST request is more for changing or updating data
in a database and GET is more for changing how the data is viewed.  Is
my understanding wrong?  Honestly, I am a python programmer who is
picking up web development as I go.

In addition, I've been trying to implement this so it works without
javascript if necessary (I've read that this is the best practice if
possible).  If I were to implement this w/out javascript with POST
wouldn't I need to pass all the parameters via the URL?

How does youtube shorten their URLs?

Finally,  the code snippet your proposed would work, but what I was
trying to do by returning both an image and HTML in a request is
remove the separation between my two views.

On Dec 26, 5:39 am, Hinnack  wrote:
> if you want to offer lots of properties one can change, POST via ajax is the
> better way - as you said
> long URLs can get very ugly - although you could shorten them like youtube
> or others do it.
> GET is far better at this point of time, as only GET requests are cachable
> (as far as I know) by djangos
> middleware.
>
> if I understand you right: you want to mix html with image-data? That is
> impossible. But you can
> add parameters to the header of the http response of the image and put in
> there all settings needed to render the image...
> So you need 2 urls - although you could add a second variable to the url
> e.g. output:
> url(r'^graph_example/(?P\d+)/(?P\w+)/$')
>
> and then a view:
>
> def myview(request, id, output):
>    if output == 'image':
>      # output image data
>    else:
>       # output html data
>
> 2009/12/26 heaviside x 
>
> > Hello,
>
> > To start, this is not another how do I get matplotlib to work in
> > Django thread.  This is how do I get matplotlib to work better with
> > django.  Before I go on, let me outline what I'm doing.
>
> > I'm currently working on a scientific data manager/viewer which uses
> > matplotlib as the primary graphing workhorse.  My intention is to be
> > able to easily handle all sorts of crazy scientific plots (Smith
> > Charts, Polar Plots with negative values, and other crazy mappings).
> > In the past, matplotlib has been able to easily and elegantly handle
> > these charts, so I'm sticking with it for now.  I also want to be able
> > to take these generated plots and quickly dump them into documents or
> > reports so a save functionality (or drag and drop via the browser) is
> > key.
>
> > Currently, my application is based off the standard matplotlib
> > example.  I have a webpage that contains a static graph.png image and
> > I point that url to another view that renders my matplotlib png and
> > returns it.
>
> > url(r'^graph_example/(?P\d+)/$')
> > url(r'^graph_example/(?P\d+)/graph.png')
>
> > How should I implement editable scales, titles, and labels?  For
> > instance, the graph comes up but I want a different scaling for a
> > report.  I could add all this information as url variables to the
> > view, but that would be extremely ugly.  Is the simple solution a
> > query string?  However, this also yields very ugly URLs.
>
> > Instead of just returning an image in the HttpResposne as the django/
> > matplotlib example shows, is there a way to return the image with the
> > rest of the base page's response?  Removing the need for hard coding a
> > "graph.png" url into my template.
>
> > Any help would be greatly appreciated.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Matplotlib with Django

2009-12-26 Thread Hinnack
if you want to offer lots of properties one can change, POST via ajax is the
better way - as you said
long URLs can get very ugly - although you could shorten them like youtube
or others do it.
GET is far better at this point of time, as only GET requests are cachable
(as far as I know) by djangos
middleware.

if I understand you right: you want to mix html with image-data? That is
impossible. But you can
add parameters to the header of the http response of the image and put in
there all settings needed to render the image...
So you need 2 urls - although you could add a second variable to the url
e.g. output:
url(r'^graph_example/(?P\d+)/(?P\w+)/$')

and then a view:

def myview(request, id, output):
   if output == 'image':
 # output image data
   else:
  # output html data



2009/12/26 heaviside x 

> Hello,
>
> To start, this is not another how do I get matplotlib to work in
> Django thread.  This is how do I get matplotlib to work better with
> django.  Before I go on, let me outline what I'm doing.
>
> I'm currently working on a scientific data manager/viewer which uses
> matplotlib as the primary graphing workhorse.  My intention is to be
> able to easily handle all sorts of crazy scientific plots (Smith
> Charts, Polar Plots with negative values, and other crazy mappings).
> In the past, matplotlib has been able to easily and elegantly handle
> these charts, so I'm sticking with it for now.  I also want to be able
> to take these generated plots and quickly dump them into documents or
> reports so a save functionality (or drag and drop via the browser) is
> key.
>
> Currently, my application is based off the standard matplotlib
> example.  I have a webpage that contains a static graph.png image and
> I point that url to another view that renders my matplotlib png and
> returns it.
>
> url(r'^graph_example/(?P\d+)/$')
> url(r'^graph_example/(?P\d+)/graph.png')
>
> How should I implement editable scales, titles, and labels?  For
> instance, the graph comes up but I want a different scaling for a
> report.  I could add all this information as url variables to the
> view, but that would be extremely ugly.  Is the simple solution a
> query string?  However, this also yields very ugly URLs.
>
> Instead of just returning an image in the HttpResposne as the django/
> matplotlib example shows, is there a way to return the image with the
> rest of the base page's response?  Removing the need for hard coding a
> "graph.png" url into my template.
>
> Any help would be greatly appreciated.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Matplotlib with Django

2009-12-26 Thread heaviside x
Hello,

To start, this is not another how do I get matplotlib to work in
Django thread.  This is how do I get matplotlib to work better with
django.  Before I go on, let me outline what I'm doing.

I'm currently working on a scientific data manager/viewer which uses
matplotlib as the primary graphing workhorse.  My intention is to be
able to easily handle all sorts of crazy scientific plots (Smith
Charts, Polar Plots with negative values, and other crazy mappings).
In the past, matplotlib has been able to easily and elegantly handle
these charts, so I'm sticking with it for now.  I also want to be able
to take these generated plots and quickly dump them into documents or
reports so a save functionality (or drag and drop via the browser) is
key.

Currently, my application is based off the standard matplotlib
example.  I have a webpage that contains a static graph.png image and
I point that url to another view that renders my matplotlib png and
returns it.

url(r'^graph_example/(?P\d+)/$')
url(r'^graph_example/(?P\d+)/graph.png')

How should I implement editable scales, titles, and labels?  For
instance, the graph comes up but I want a different scaling for a
report.  I could add all this information as url variables to the
view, but that would be extremely ugly.  Is the simple solution a
query string?  However, this also yields very ugly URLs.

Instead of just returning an image in the HttpResposne as the django/
matplotlib example shows, is there a way to return the image with the
rest of the base page's response?  Removing the need for hard coding a
"graph.png" url into my template.

Any help would be greatly appreciated.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.