what exactly is your "error"? Is your matplotlibrc correct? If you will be using matplotlib maybe this example from an data application i wrote may help you:
def calculate_myPic(my_args): fig = figure(figsize=parameter.figsize) plotarea = fig.add_subplot(111) # for my thing # calculate your data plotarea.bar(...) # eg. plot bars plotarea.plot_date(...) # or a date based graph title("my title" ) xlabel("ordinate") # eg. x-axis # write it out on a png, *depending on matplotlibrc* out = django.http.HttpResponse(content_type='image/png') fig.savefig(out) close() return out Am Donnerstag, den 02.08.2012, 00:46 -0400 schrieb Peregil: > Well, I have been trying, but I cannot get the graph or error from the > function... > > > I will keep trying,.. > > > > > > > On Wed, Aug 1, 2012 at 5:42 PM, william ratcliff > <william.ratcl...@gmail.com> wrote: > Can you attach an example png? If it's not too complex, you > might be able to do this all clientside as well... > > > > > William > > > On Wed, Aug 1, 2012 at 5:41 PM, william ratcliff > <william.ratcl...@gmail.com> wrote: > If you're planning on adding this to your views.py, > then you want to move the import statements to the top > of the file (outside of simple), so they aren't called > every time. Don't import django. > > > > > William > > > On Wed, Aug 1, 2012 at 4:06 PM, Peregil > <pereg...@gmail.com> wrote: > Great thanks... > > > I found this function... it seems > complicated, but it is kind of working... I > hope that I can include it in a my web page... > > > # file charts.py > def simple(request): > import random > import django > import datetime > > from matplotlib.backends.backend_agg import > FigureCanvasAgg as FigureCanvas > from matplotlib.figure import Figure > from matplotlib.dates import DateFormatter > > fig=Figure() > ax=fig.add_subplot(111) > x=[] > y=[] > now=datetime.datetime.now() > delta=datetime.timedelta(days=1) > for i in range(10): > x.append(now) > now+=delta > y.append(random.randint(0, 1000)) > ax.plot_date(x, y, '-') > > ax.xaxis.set_major_formatter(DateFormatter('%Y-%m-%d')) > fig.autofmt_xdate() > canvas=FigureCanvas(fig) > > response=django.http.HttpResponse(content_type='image/png') > canvas.print_png(response) > return response > > On Wed, Aug 1, 2012 at 3:31 PM, Daniel Molina > Wegener <d...@coder.cl> wrote: > On 01/08/12 15:19, Peregil wrote: > I need to have the graphic on > a web page... as soon as a > user hit summit... > > > If you need to draw a graph, you can > try the pygraphviz. > > If you need to plot a chart, you can > matplotlib, if that is not > so easy to implement, you can try > using django google charts packages: > > > > http://pypi.python.org/pypi/django-googlecharts/1.0-alpha-1 > > > > http://pypi.python.org/pypi/django-google-charts/0.1.1 > > > > > On Wed, Aug 1, 2012 at 3:16 > PM, william ratcliff > > <william.ratcl...@gmail.com > <mailto:william.ratcl...@gmail.com>> > wrote: > > As a quick hack, you could > generate a postscript file > using > savefig(). Then, you > could print that from the > commandline to a > local printer--If they > don't need a physical > printout, I would > generate a pdf file and > serve it to them and let them > print it. If > I figure out how to print > directly using the printer > dialog, I'll > let you know... > > William > > > On Wed, Aug 1, 2012 at > 2:05 PM, Peregil > <pereg...@gmail.com > > > <mailto:pereg...@gmail.com>> > wrote: > > it is an > intranet, and I don't have any > restrictions > using JavaScript... > abd I am using matplotlib... I > thing it is > the only way to save a > file and put it on the web > page... > > > > On Wed, Aug 1, 2012 at > 1:59 PM, william ratcliff > > > <william.ratcl...@gmail.com > <mailto:william.ratcl...@gmail.com>> > > wrote: > > What are you using > for your plotting package? > Matplotlib? > I think that this > will show the plot (on the > server > machine)--the > easiest thing I can think of > for now (assuming > that you are using > matplotlib) is to generate a > pdf and send > them the file. I > haven't tried printing > directly--is this > intranet, or > external facing? Do you have > any restrictions > on using > javascript? > > William > > > On Wed, Aug 1, > 2012 at 12:58 PM, Peregil > <pereg...@gmail.com > > > <mailto:pereg...@gmail.com>> > wrote: > > a user to > print one > > I did this in > python, but throws an error in > django when > I tried to run > it... I have seen some > examples of saving > an image, but > I would like to avoid that > since I don't > want to open > and close a file... > > let me know if > you have any idea.... > > thanks > > Python > program: > > > def > drawPlot(arrayGene1, > arrayGene2): > message = > '' > (m,b) = > polyfit(arrayGene1,arrayGene2,1) > yp = > polyval([m,b],arrayGene1) > > xlable('Gene 1') > > ylable('Gene 2') > > title('Correlation Graph') > > plot(arrayGene1, yp) > > > scatter(arrayGene1,arrayGene2,marker='>') > show() > > return(message) > > > > On Wed, Aug 1, > 2012 at 12:21 PM, william > ratcliff > > <william.ratcl...@gmail.com > > > <mailto:william.ratcl...@gmail.com>> > wrote: > > Do you > need to display a graph, or > allow the user to > print one? > > On Wed, > Aug 1, 2012 at 12:06 PM, > Peregil > > > <pereg...@gmail.com > <mailto:pereg...@gmail.com>> > wrote: > > The > information comes from a > database, which I > got it > with a problem. However, I > need to show a > graph > as well. > > Please > let me know any suggestions... > > thanks > and have great day. > > -- > You > received this message because > you are > > subscribed to the Google > Groups "Django users" > group. > To > post to this group, send email > to > > django-users@googlegroups.com > > > > <mailto:django-users@googlegroups.com>. > > To > unsubscribe from this group, > send email to > > django-users > +unsubscr...@googlegroups.com > > > <mailto:django-users% > 2bunsubscr...@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-users@googlegroups.com > > > > <mailto:django-users@googlegroups.com>. > > To > unsubscribe from this group, > send email to > > django-users > +unsubscr...@googlegroups.com > > > <mailto:django-users% > 2bunsubscr...@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-users@googlegroups.com > > > > <mailto:django-users@googlegroups.com>. > > To unsubscribe > from this group, send email to > django-users > +unsubscr...@googlegroups.com > > > <mailto:django-users% > 2bunsubscr...@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-users@googlegroups.com > > > > <mailto:django-users@googlegroups.com>. > > To unsubscribe > from this group, send email to > django-users > +unsubscr...@googlegroups.com > > > <mailto:django-users% > 2bunsubscr...@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-users@googlegroups.com > > > > <mailto:django-users@googlegroups.com>. > > To unsubscribe from > this group, send email to > django-users > +unsubscr...@googlegroups.com > > <mailto:django-users% > 2bunsubscr...@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-users@googlegroups.com > > > > <mailto:django-users@googlegroups.com>. > > To unsubscribe from this > group, send email to > django-users > +unsubscr...@googlegroups.com > > <mailto:django-users% > 2bunsubscr...@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-users@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. > > > Best regards, > -- > Daniel Molina Wegener <dmw [at] coder > [dot] cl> > System Programmer & Web Developer > Phone: +56 (2) 979-0278 | Blog: > http://coder.cl/ > > > -- > You received this message because you > are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to > django-users@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-users@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. > > > > > > > > -- Armaturen und Fittings Stüss e.K. Frank Stüss + Inhaber Tel. +49+6187-5019 + FAX. +49+6187-91725 Kilianstädter Straße 25 + D-61137 Schöneck email frank.stu...@stuess.de <http://www.stuess.de> Sitz Schöneck, HRA5340, Amtsgericht Hanau USt.-ID: DE252310440 ............................................ Fördermitglied der Wirtschaftsjunioren Hanau-Gelnhausen-Schlüchtern Umfassende Infos: http://www.wj-hanau.de Senator #68128 -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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.