[Matplotlib-users] linear regression with dates as x axis
Hi all, I have some time series of disk usage that I'd like to do a linear regression on an plot on a nice graph with Mb used on the y-axis and date on the x axis. I tried to use pylab.polyfit(dates, usage) where: dates = [datetime(x, y, z), datetime(a, b, c), ...] usage = [12123234, 2234235235, ...] ...but polyfit doesn't like the dates. How should I do this? Any example of a nice plot and linear regression using matplotlib? cheers, Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [SciPy-User] getting started with arrays and matplotlib
On 07/08/2011 22:29, David Warde-Farley wrote: Secondly, once I've populated this, any good examples of how to turn it into a bar chart? (the simple bar chart would be number of sales on the y-axis, weeks before the event on the x-axis, however, what I'd then like to do is split each bar into chunks for each venue's sales, if that makes sense?) This might give you an example of what you need: http://matplotlib.sourceforge.net/examples/pylab_examples/bar_stacked.html but you'd be better off asking on matplotlib-users. Thanks, that was a good start. One question: How can I automatically get a list of colours for each bar? I don't know how many bars I'm going to have so I can't manually pick them... This feels like a common enough problem that I'm guessing there's a solution somewhere in matplotlib? cheers, Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Tutorial on working with Excel files in Python (without COM and cross platform!) at EuroPython 2009
Hi All, Too many people in the Python community *still* think the only way to work with Excel files in Python is using COM on Windows. To try and correct this, I'm giving a tutorial at this year's EuroPython conference in Birmingham, UK on Monday, 29th June that will cover working with Excel files in Python using the pure-python libraries xlrd, xlwt and xlutils. I'll be looking to cover: - Reading Excel Files Including extracting all the data types, formatting and working with large files. - Writing Excel Files Including formatting, many of the useful frilly extras and writing large excel files. - Modifying and Filtering Excel Files A run through of taking existing Excel files and modifying them in various ways. - Workshop for your problems I'm hoping anyone who attends will get a lot out of this! If you're planning on attending and have a particular problem you'd like to work on in this part of the tutorial, please drop me an email and I'll try and make sure I come prepared! All you need for the tutorial is a working knowledge of Excel and Python, with a laptop as an added benefit, and to be at EuroPython this year: http://www.europython.eu/ I look forward to seeing you all there! Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk -- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Tutorial on working with Excel files in Python(without COM and cross platform!) at PyConUS 2009
Derek Hohls wrote: I hope I speak for others when I say: for those of us who cannot be at PyCon, please consider making tutorials etc available for download afterwards. We'd love to be able to spread the good word about these excellent libraries. Keep an eye out on the PyConUS website after the conference, I believe they'll make the tutorials available there... cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Tutorial on working with Excel files in Python (without COM and cross platform!) at PyConUS 2009
Hi All, Too many people in the Python community think the only way to work with Excel files in Python is using COM on Windows. To try and correct this, I'm giving a tutorial at this year's PyCon in Chicago on Wednesday, 25th March that will cover working with Excel files in Python using the pure-python libraries xlrd, xlwt and xlutils. I'll be looking to cover: - Reading Excel Files Including formatting, unicode dates and formulae. - Writing Excel Files Including formatting with easyxf and things like freeze pains, print areas, etc - Filtering Excel Files A run through on the structure of xlutils.filter and some examples to show you how it works. - Workshop for your problems I'm hoping anyone who attends will get a lot out of this! If you're planning on attending and have a particular problem you'd like to work on in this part of the tutorial, please drop me an email and I'll try and make sure I come prepared! All you need for the tutorial is a working knowledge of Excel and Python, with a laptop as an added benefit, and to be at PyCon this year: http://us.pycon.org I look forward to seeing you all there! Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib threadsafe?
Eric Firing wrote: Out of interest, how does one tell MPL to start a new figure and forget everything that's gone before? You can minimize the amount of package and module-level state information by using the oo interface: see examples/agg_oo.py. I tried this example, and it generates no output. Is that to be expected? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] location of figure window
Hey All, Is there any way I can control the location that a tk figure window is shown on screen? I can control the size fine with: pylab.figure(figsize=(10,10)) ...but this produces a figure that, while it's the right size, is rendered with the top left of the window in the middle of the screen. If I can get it to be to-left, then it will all be visisble without me having to move it with a mouse ;-). Any ideas? Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] plotting from a dictionary
Hey All, I have a dictionary that maps date to a count (in this case the number of false negatives from my spam filter) and I'm wondering how to best plot something that looks like, say: from datetime import date data = { date(2008,03,01):10, date(2008,03,02):15, date(2008,03,03):13, } I'm worried about getting the dates out in order such that I get a straight line plot, rather than the zigzag back-and-forth line I reckon I'd get if I did: dates = [] count = [] for date,count in data.items: dates.append(date) count.append(count) plot(dates,counts) cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [newbie] live plots of multiple lines
Matthias Michler wrote: I'm not sure it is the easiest way, but it works for me: for label in ax.xaxis.get_majorticklabels(): label.set_rotation(+90) Yes, that's what I was using, just wondered if there was a better way... Also, how would I get this kind of updating with bar charts or errorbars? In the case of bar charts and errorbars it is quite difficult to reset the data. Oh, I also meant to ask about scatter, can the data be easilly reset there? For bar charts and errorbar plots, I agree ;-) How would I just blank the figure and replot? (I have just been calling errorbar lots, but I'm guessing that if I add a legend, I'll have one entry for each time I called errorbar :-S) cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [newbie] live plots of multiple lines
Matthias Michler wrote: the above script leads to a different behaviour on my system. What is that behaviour and what version of matplotlib are you using? I think it is the expected behaviour. The number of xtick is aproximately constant and some tick get sorted out, when the xlimits are increasing. I'm using matplotlib-svn r5024 on Debian etch. Hmm, do you have a code snippet to demonstrate this? Maybe I'm missing some vital step that causes the axis to re-calculate its ticks? sorry. I have no idea where this problems comes from. I have seen that using idle and the latest release of matplotlib on and winxp, but I can't reproduce it on my linux system. *sigh* ;-) Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [newbie] live plots of multiple lines
Matthias Michler wrote: I'm not sure that I understand you correctly. The code I refering is the one which I attached some mails ago. The following works for me: Ah, okay, to get the problem I was having, change your script as follows: - from pylab import * from datetime import datetime from time import sleep ion() # interactive mode 'on' figure() ax = subplot(111, autoscale_on=True) x, y = [datetime.now()], [0] line = plot(x, y, label=my_data)[0] # get the line-object as the first element # of the tuple returned by plot legend() for i in arange(30): x.append(datetime.now()) # append new values y.append(i**2) line.set_data(x,y)# reset data ax.relim()# reset axes limits ax.autoscale_view() # rescale axes draw()# redraw current figure sleep(0.3)# wait 0.3 seconds ioff() show() So, basically make the x axis time instead of numbers. I think the problem is actually that the daets are quite long in their format. If they were rotated through 90 degress it'd likely be fine. How would I do this? Also, how would I get this kind of updating with bar charts or errorbars? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [newbie] live plots of multiple lines
Matthias Michler wrote: My x-axis is time, and as new points are plotted, even though I'm following the above recipe pretty closely, the x-tick spacing isn't getting sorted out, so I end up with just a jumble as the tick labels for the x-axis. Do you know why this might be? I'm not sure I understand correctly, but if the number of xticks increases dramatically (nobody could see the individual ticks), Indeed, it looks like the Tick spacing is staying as it was when the first point was plotted, so when hundreds more points are plotted, I just get a jumble of labels on the x-axis. the above script leads to a different behaviour on my system. What is that behaviour and what version of matplotlib are you using? Shame I get that horrible exception when I do close the plot window, wish I knew how to make it stop :-S I don't know which exception you refer to, but sometimes if gives problems if the interactive mode wasn't switched off (ioff()) before the scripts ends or show() is called. If I run the attached script, and hit Ctrl-C in the DOS box running it, I get: C:\python mpltest.py Traceback (most recent call last): File mpltest.py, line 3, in module show() File C:\Python25\Lib\site-packages\matplotlib\backends\backend_tkagg.py, li e 76, in show Tk.mainloop() File C:\Python25\lib\lib-tk\Tkinter.py, line 328, in mainloop _default_root.tk.mainloop(n) KeyboardInterrupt Fatal Python error: PyEval_RestoreThread: NULL tstate This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. I've had a similar error when I hit the red cross in the corner of the window with other scripts, although not this one :-S cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk from pylab import * plot([1,2],[3,4]) show() - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] I really need help about installing matplotlib.
lovegf86 wrote: What is the problem? Do I need to update numpy? Please help me, I am so desperate.. Install Python 2.5 from here: http://python.org/ftp/python/2.5.2/python-2.5.2.msi Install NumPy from here: http://downloads.sourceforge.net/numpy/numpy-1.0.4.win32-p3-py2.5.exe Install the windows binary for python 2.5 from here: http://downloads.sourceforge.net/matplotlib/matplotlib-0.91.2.win32-py2.5.exe Ignore the Enthought stuff ;-) cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Runtime Error
Hi Brook, Brook Lin wrote: raise RuntimeError('%s' is not a writable dir; you must set %s/.matplotlib to be a writable dir. You can also set environment variable MPLCONFIGDIR to any writable directory where you want matplotlib data stored %h) This is the crucial bit. Looks like you've set MPLCONFIGDIR to a read-only dir, or the .matplotlib in the current dir or .matplotlib in your home directory aren't writeable by the user running your python script. (I'm doing a bit of guesswork here...) What is it that you're trying to do? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plotting dates on the Y axis?
Kenneth Miller wrote: Is it possible to plot dates on the Y-axis? I'd like to have dates on the y axis descending or ascending versus my values on the x - axis. Is it possible to do this or simply switch the axis? Not sure what you mean, have you just tried it with plot or plot_dates? What problems are you experiencing? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting filled lines with missing data?
Pierre GM wrote: Your data is indexed in time, right ? Your x-axis is a date object ? Then use scikits.timeseries http://scipy.org/scipy/scikits/wiki/TimeSeries I'm not sure what this is giving me. The dates are all python datetimes in a list already. The missing values started off as '', I turned those into nan and then created a ma with the nan's masked. What more would TimeSeries give me? the link above. I must admit we didn't implement poly_between for timeseries. Most likely, we'd have to implement it for regular masked arrays first, as mentioned by Eric. OK. What you could do is to fill your array with some kind of baseline, such as 0, or your minimum data, or wtvr. That's just a quick trick and no fix. Indeed, that's what I had to do. I have to admit, I see some interesting things while scanning that wiki page, but nothing that would have helped me... cheers, Chris (who might well be missing something...) -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plotting dates on the Y axis?
Kenneth Miller wrote: back in time. When i pass plot_dates timestamps for the y axis, and integers for the x axis it simply displays the y-axis as floats. did you try: plot_dates(x,dates,ydate=True) ? Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [newbie] live plots of multiple lines
Hey Matthias, Matthias Michler wrote: maybe something like the following helps you: - from pylab import * from time import sleep ion() # interactive mode 'on' figure() ax = subplot(111, autoscale_on=True) x, y = [0], [0] line = plot(x, y, label=my_data)[0] # get the line-object as the first element # of the tuple returned by plot legend() for i in arange(10): x.append(i) # append new values y.append(i**2) line.set_data(x,y)# reset data ax.relim()# reset axes limits ax.autoscale_view() # rescale axes draw()# redraw current figure sleep(0.5)# wait 0.5 seconds ioff() This is perfect, except for one little thing... My x-axis is time, and as new points are plotted, even though I'm following the above recipe pretty closely, the x-tick spacing isn't getting sorted out, so I end up with just a jumble as the tick labels for the x-axis. Do you know why this might be? I don't know how to make this somehow interactive concerning the data input. but maybe you save the data to a file and read them every 15 or 20 minutes. This isn't a problem, I just run in a while True loop and leave it running until I close the plot window. Shame I get that horrible exception when I do close the plot window, wish I knew how to make it stop :-S cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting filled lines with missing data?
Eric Firing wrote: Both with respect to documentation and functionality, what you are encountering is the historical aspect of masked arrays as a tacked-on part of python numeric packages, and of matplotlib. *sigh* I feel lucky ;-) Support and integration are improving, but still far from perfect. I wish I could help, but my knowledge is lacking... Now with respect to your particular case here, trying to plot a filled line with gaps: poly_between has no notion of masked arrays at present. If it did, how should it behave? Well, what I actually settled on was juat doing using: my_masked_array.filled(0) ...to plot with. At the very least, additional arguments are needed to specify what should happen for fill-type plotting with missing values. Indeed, what I personally would have liked was a complete gap where the data is missing, but I guess that would have to return multiple polygons, and I don't know how that would work? provide them in mpl. I would be happy to fix this gap in mpl's handling of gappy data, ...heh ;-) but I can't make it a priority use of my time right now. No, I understand :-) cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting with missing data?
Giorgio F. Gilestro wrote: import numpy as np a = ['','','',1.1,2.2] mask_a = [i == '' for i in a] b = np.ma.MaskedArray(a, mask=mask_a) Not very efficient, though, is it? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib threadsafe?
Michael Droettboom wrote: At least the Agg backend *looks* to be reasonably threadsafe -- there are no obvious gotchas like global variables etc. Note, though, that multithreading may not gain much in the way of performance since the global interpreter lock is never released around long-running C blocks. It's not performance I'm looking for, it's making sure that MPL apps served from multi-threaded wsgi servers don't screw each others charts up ;-) cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib threadsafe?
Eric Firing wrote: In general, I don't think mpl is threadsafe at all; it uses global variables, such as all the rc parameters, that could easily be modified by one thread while being used by another. Yep, I guessed as much, BFL it is then ;-) I think that great care would be needed if one wanted to have multiple threads making plots. Having one plotting thread and any number of threads doing other things, however, should be OK. Out of interest, how does one tell MPL to start a new figure and forget everything that's gone before? At the very least, I think we would have to take all the global state information and put it in a class instance, so there could be multiple plotting machines. Yes. cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] compiling from svn on windows
Michael Droettboom wrote: That's cool'n'all, but when is svn going to make it into a Windows binary release? ;-) I suspect your question is somewhat rhetorical, but... it will probably be a while ;) Why is that? Who cranks out the binary releases on Windows and what compiler do they use? I know a lot of people (myself included) have had success with MinGW. What's the official compiler used, though? It's a good learning experience, and there's lots on this list willing to help. If we can get more SVN Windows users on board, more crazy Windows-only bugs will get found and squashed sooner... ;) Well, tell me how to get the svn trunk and how to compile and I'll give it a go :-) cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] gradient fills for bar charts?
Eric Firing wrote: Short of laboriously putting an image in each bar, no. That's a shame :-( So, no gradient filled patches in MPL? Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting with missing data?
Pierre GM wrote: Could you send me an example of the kind of data you're using ? It's basically performance and volume data for a high-volume website. Unfortunately, the data is gappy in places due to data collection errors in the past... (it's important the gaps are shown, rather than trying to interpolate them away, however) As it seems you're dealing with series indexed in time, you may want to try scikits.timeseries, a package Matt Knox and myself implemented for that very reason. How would this help me here and where can I find out about it? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] making minor ticks into lines instead of ticks
Eric Firing wrote: I can get the major ticks to show by doing grid(True), but how do I get the same effect for minor ticks? Try grid(True, which='minor') Thanks, that worked (well, it did what it was supposed to...) so it'd be nice if it was in the online docs as well as the docstring of the method;-) However, this isn't quite what I want... I only want the grid for the y-axis (ie: horizontal lines in the grid, but no vertical), how would I do that? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting with missing data?
Eric Firing wrote: Specifically, what I have is an array like so: ['','','',1.1,2.2] Try something like this: import numpy.ma as ma from pylab import * aa = [3.4, 2.5, '','','',1.1,2.2] def to_num(arg): if arg == '': return .0 return arg aanum = array([to_num(arg) for arg in aa]) aamasked = ma.masked_where(aanum==.0, aanum) plot(aamasked) show() What I ended up doing was getting my array to look like: from numpy import nan aa = [3.4,2.5,nan,nan,nan,1.1,2.2] values = numpy.array(aa) values = numpy.ma.masked_equal(values,nan) I only wish that masked_equal didn't blow up when aa contains datetime objects :-( cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] from pylab import nx?
Hi All, A few of the units demos include the lines: from pylab import nx ...but this import errors for me. Why is that? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] making minor ticks into lines instead of ticks
Matthias Michler wrote: ax.yaxis.grid(which='minor') This is what I was after, thankyou :-) However, the lines show up on top of the lines plotted, not behind them as I'd expect. I tried fiddling with the zorder of the plot and the grid but nothing had any effect. What am I doing wrong? How do I get the grid to show up behind the lines? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] default zorder for plots?
Chris Withers wrote: I tried fiddling with the zorder of the plot and the grid but nothing had any effect. What am I doing wrong? How do I get the grid to show up behind the lines? Actually, I did manage to fix this by specifying a zorder of 10 for the plots and a zorder of 1 for the grids. What's the default zorder? Ideally I'd just like to supply the zorder to the grids... cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] bar chart with dates on x-axis blows up
Hi All, I'm trying to plot a bar chart something like: from pylab import * from datetime import datetime,timedelta now = datetime.now() data1 = [1,2,3] data2 = [4,5,6] labels = [now-timedelta(1),now,now+timedelta(1)] bar(labels,data1) show() However, this blows up: Traceback (most recent call last): bar(labels,data1) File matplotlib\pyplot.py, line 1402, in bar ret = gca().bar(*args, **kwargs) File matplotlib\axes.py, line 3294, in bar self.add_patch(r) File matplotlib\axes.py, line 1146, in add_patch self._update_patch_limits(p) File matplotlib\axes.py, line 1152, in _update_patch_limits xys = self._get_verts_in_data_coords( File matplotlib\patches.py, line 362, in get_verts right = self.convert_xunits(x + self.width) TypeError: unsupported operand type(s) for +: 'datetime.datetime' and 'float' What am I doing wrong? Also, how do I go about adding a second set of bars? (ie: from data2)? (Bear in mind that in the real use, there are over 600 days worth of data, so I want to take advantage of the normal tick locators, etc as much as possible...) cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] placing legend outside of plot area
Matthias Michler wrote: - I think this could be a good improvement, but i'm not sure if it is easy to expand the functionality of the axes-legend (pyplot.legend or ax.legend) to that of a figure-legend(pyplot.figlegend or fig.legend with fig as a figure instance) without missing something, because there is no axes specified and therefore it is not obvious which lines should be displayed. True, although if there's only one axes, it's obvious ;-) (and if there's more than one, it should take an axes as a keyword parameter) In that case the default behaviour might become to take all lines from all axes and that's not what one always needs, or isn't it? Who knows, maybe someone would want that? The joy of building generic tools ;-) ax1 = subplot(111) # some plotting commands labels = [] for line in ax1.lines: label = line.get_label() labels.append(label) # or in one line: # labels = [line.get_label() for line in ax1.lines] figlegend(ax1.lines, labels, 'upper right') Yes, you see, it just feels to me like figlegend should have this code in it as it's likely to be duplicated every time I need to call figlegend. Why not just? figlegend(axes=ax1,'upper right') - it places the legend over the top of the current chart, I want it to the right, so it doesn't obscure the information on the chart... That's true and I have no idea how to overcome that (except for example subplot_adjust(top=0.8)). Yes, I'm just making do with this for now, but it would be really nice if MPL supported legends outsite the axes properly. It would also be good if you didn't have to manually fiddle with subplot_adjust because you rotated the labels for the x-axis through 90 degrees :-( How does figure.legend interact with subplots? I'm don't know, but maybe it doesn't interact with the axes / subplots at all. 'badly' I think is the best summary of the interaction ;-) I think in that case the axes-legend is the preferred one, but I have no idea how to ensure that nothing is cover by the legend without difficult tuning of the parameters or at least ensure that all labels have the same widths. Yeah :-/ This is where I am... If anyone has any magic code or suggestions, I'd love to hear 'em ;-) Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Gappy bars when no edge specified?
Hi All, Why does the following render small gaps horizontally between the bars? import pylab data = [1,2,1,2,4,2] labels = pylab.arange(len(data1)) pylab.bar(labels,data1,width=1,linewidth=0) pylab.show() How do I make the small gaps go away? cheers, Chris - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] gradient fills for bar charts?
Hi All, Is there any way in MPL to do gradient filled bars like you can in Excel? (click data series - format data series - patterns - fill effects - gradient - diagonal up) cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Gappy bars when no edge specified?
Eric Firing wrote: How do I make the small gaps go away? With svn I don't see any gaps in the example above, either on screen or when saved to a png file. That's cool'n'all, but when is svn going to make it into a Windows binary release? ;-) cheers, Chris - not sure how to compile MPL on Windows :-( -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting with missing data?
Eric Firing wrote: Chris, Use masked arrays. See masked_demo.py in the mpl examples subdirectory. Hi Eric, I took a look at that, but it uses: import matplotlib.numerix.npyma as ma ...and matplotlib.numerix isn't listed in the API reference. Where are the docs for this? Specifically, what I have is an array like so: ['','','',1.1,2.2] I want to mask the strings out so I don't get ValueErrors raised when I call plot functions with that array. How should I do that? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] placing legend outside of plot area
Hi All, How would I go about placing the legend outside the plot area? All the parameters to legend seem to place the legend somewhere within the plot and I'd like to place it outside the plot, either above, below or, most commonly, to the right, in the same way as the Excel legend positions allow. cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] placing legend outside of plot area
Hi Matthias, Matthias Michler wrote: I'm not sure if there was an example in matplotlib, but the following works for me: - from pylab import * figure() subplot(111) subplots_adjust(right=0.7) plot(arange(10), label='linear') plot(arange(10)**2, label='quadratic') legend(loc=(1.1,0.5)) show() Thanks for this. This is exactly what I was after except that the legend now appears about 25% off the right hand of the screen or whatever I save the figure to. How can I have the legend as placed above but with the whole of it showing? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] how to remove an xlabel?
Matthias Michler wrote: you can try xlabel of an empty string: xlabel(' ') Thanks, and yes, a truly empty string xlabel(''), works :-) cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] placing legend outside of plot area
Matthias Michler wrote: sorry I don't understand what you are exactly looking for. Maybe you could explain it once more. Well, what you provided was pretty close, it's just that the legend was partly placed outside the figure... In general I think all one can do is to play around with the parameters in 'subplots_adjust' and the location in 'legend' to get the best result. I'm not an expert but I think there's no default behaviour covering all needs (outside the axes and best located), because for example the legend width is influenced by the length of the labels. Right, this is the problem. The location your example provided is perfect, except that I may have no control over the length of the legend text, and so need to find a way to make sure the figure size is such that the legend doesn't end up being half off the figure... Anyone know how to do that? (and thanks to Matthias for all his help! :-) ) cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] visualisation for utility usage sought
(meant this to go to the list too) Christiaan Putter wrote: I'm having trouble understanding what it is you exactly want. That's likely my fault ;-) You said you want to indicate that 'the monthly usage between September 1st and January 1st was, on average, the same as that between January 1st and February 1st.' Yes, but monthly is a red herring here, the time periods are however long it's been since myself or the utility company checked the meter ;-) The measurement your taking is not in fact the utility usage for one month, but rather the sum of all usage over all prior months. Not really, and this was definitely me being unclear... We're talking about utility meters here, so you go and look at them and they show how many units of whatever it is (water, electicity, etc) they have delivered. So, that's how you get the time series (with more variation, to show reality, and avoid red herrings like month): 2007/09/13 - 5000 2008/01/02 - 8000 2008/02/08 - 9000 2008/02/12 - 9100 So, the differences tell us: Between 2007-09-13 and 2008-01-02, 3000 units were used Between 2007-01-02 and 2008-02-08, 1000 units were used Between 2007-02-08 and 2008-02-12, 100 units were used So I guess it's this data that I'm looking to visualise in such a way that it's apprarent how much of the utility is being per unit time. NB: The measurements aren't regular, since they often come from when a person turns up and reads the meter, which isn't at all regular ;-) Does that make more sense? Any ideas? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] plotting with missing data?
Hi All, Say I have data that looks like: date x y z 2008-01-01 10 2008-01-02 21 11 2008-01-02 32 15 5 How can I plot it such that all three lines are plotted by that it's apparent two of them are missing some data? (I know I could just sub in zeros for the missing values, but I'd like the point not to be there, not just down the bottom of the graph...) cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Export plot to Word
Cheng-Kong Wu wrote: I created several plots and want to export them to a Word file sequentially, how can I do that? Why Word? It's a horrible file format and very difficult to deal with. Why not just use one of the PDF backends (I don't think I'm making that up, there are PDF back ends for Matplotlib, right?) If you really insist on trying with Word, your best bet is to interact with Word via the win32com package... cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [newbie] live plots of multiple lines
Matthias Michler wrote: plot([x1], [y1], bo, [x2], [y2], r+) This didn't work :-S - the first time I call show(), execution never comes back to my script so the code never gets to plot any further points - if I put the show after the plotting loop (which means I don't get the live plotting I'm after) then there are no lines between the points (well, the points don't show at all, but I'm guessing it's because there's no lines between the points) - looking at the example, I'm left wondering how to pass keyword parameters such as label or use other methods such as plot_date Any help greatfully received! Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [newbie] live plots of multiple lines
Alan G Isaac wrote: On Tue, 11 Mar 2008, Chris Withers apparently wrote: the first time I call show() http://matplotlib.sourceforge.net/faq.html#SHOW Okay, that tells me that I prettymuch don't want to be using show(), but I don't think I want interactive mode either... What I'm trying to do is run a script and plot-and-show as I go. The script reads the data to be plotted, but each set of points takes up to 20 minutes to generate, so I want to see the points appear on the graph as they arrive. Is this possible? If so, how? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [newbie] live plots of multiple lines
Ryan May wrote: Right, the show() command starts the GUI's mainloop, which blocks execution of the script until you close the figure. What you probably want is something like the dynamic_demo.py example. ...which barfes for me: Traceback (most recent call last): File dynamic_demo.py, line 3, in module import gobject ImportError: No module named gobject What does that mean? Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [newbie] live plots of multiple lines
Chris Withers wrote: Matthias Michler wrote: plot([x1], [y1], bo, [x2], [y2], r+) This didn't work :-S - the first time I call show(), execution never comes back to my script so the code never gets to plot any further points Okay, thanks to Ryan, I now have this point fixed, however, with the following code: ion() i = 1 while i 5: plot([i],[i],'go',[i],[i+2],'ro') print i i+=1 sleep(0.5) draw() - there are no lines between the points, how do I get the lines to show? - how would I pass keyword parameters such as label or use other methods such as plot_date? Also, when the above script finishes, I get: Fatal Python error: PyEval_RestoreThread: NULL tstate This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. What does that mean? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] [newbie] live plots of multiple lines
Hi All, Apologies if I'm missing anything obvious... How do I plot lines point-by-point as opposed to by passing arrays? I'm guessing something like: plot([x],[y]) ...but that feels a bit weird to me. In any case, using that, I don't know how to plot more than one line at a time, so thought I'd ask here... Hope you can help! cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users