[Matplotlib-users] linear regression with dates as x axis

2012-06-13 Thread Chris Withers
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,

Re: [Matplotlib-users] [SciPy-User] getting started with arrays and matplotlib

2011-08-20 Thread Chris Withers
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

[Matplotlib-users] Tutorial on working with Excel files in Python (without COM and cross platform!) at EuroPython 2009

2009-06-18 Thread Chris Withers
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

Re: [Matplotlib-users] Tutorial on working with Excel files in Python(without COM and cross platform!) at PyConUS 2009

2009-01-27 Thread Chris Withers
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

[Matplotlib-users] Tutorial on working with Excel files in Python (without COM and cross platform!) at PyConUS 2009

2009-01-22 Thread Chris Withers
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

Re: [Matplotlib-users] matplotlib threadsafe?

2008-04-09 Thread Chris Withers
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

[Matplotlib-users] location of figure window

2008-04-09 Thread Chris Withers
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

[Matplotlib-users] plotting from a dictionary

2008-04-03 Thread Chris Withers
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,

Re: [Matplotlib-users] [newbie] live plots of multiple lines

2008-03-28 Thread Chris Withers
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

Re: [Matplotlib-users] [newbie] live plots of multiple lines

2008-03-27 Thread Chris Withers
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

Re: [Matplotlib-users] [newbie] live plots of multiple lines

2008-03-27 Thread Chris Withers
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:

Re: [Matplotlib-users] [newbie] live plots of multiple lines

2008-03-26 Thread Chris Withers
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

Re: [Matplotlib-users] I really need help about installing matplotlib.

2008-03-25 Thread Chris Withers
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

Re: [Matplotlib-users] Runtime Error

2008-03-24 Thread Chris Withers
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

Re: [Matplotlib-users] Plotting dates on the Y axis?

2008-03-21 Thread Chris Withers
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

Re: [Matplotlib-users] plotting filled lines with missing data?

2008-03-21 Thread Chris Withers
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

Re: [Matplotlib-users] Plotting dates on the Y axis?

2008-03-21 Thread Chris Withers
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 -

Re: [Matplotlib-users] [newbie] live plots of multiple lines

2008-03-21 Thread Chris Withers
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 =

Re: [Matplotlib-users] plotting filled lines with missing data?

2008-03-20 Thread Chris Withers
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

Re: [Matplotlib-users] plotting with missing data?

2008-03-20 Thread Chris Withers
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

Re: [Matplotlib-users] matplotlib threadsafe?

2008-03-20 Thread Chris Withers
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

Re: [Matplotlib-users] matplotlib threadsafe?

2008-03-20 Thread Chris Withers
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

Re: [Matplotlib-users] compiling from svn on windows

2008-03-20 Thread Chris Withers
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

Re: [Matplotlib-users] gradient fills for bar charts?

2008-03-19 Thread Chris Withers
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

Re: [Matplotlib-users] plotting with missing data?

2008-03-19 Thread Chris Withers
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

Re: [Matplotlib-users] making minor ticks into lines instead of ticks

2008-03-18 Thread Chris Withers
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

Re: [Matplotlib-users] plotting with missing data?

2008-03-18 Thread Chris Withers
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 =

[Matplotlib-users] from pylab import nx?

2008-03-18 Thread Chris Withers
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

Re: [Matplotlib-users] making minor ticks into lines instead of ticks

2008-03-18 Thread Chris Withers
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

[Matplotlib-users] default zorder for plots?

2008-03-18 Thread Chris Withers
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

[Matplotlib-users] bar chart with dates on x-axis blows up

2008-03-18 Thread Chris Withers
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

Re: [Matplotlib-users] placing legend outside of plot area

2008-03-18 Thread Chris Withers
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,

[Matplotlib-users] Gappy bars when no edge specified?

2008-03-18 Thread Chris Withers
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

[Matplotlib-users] gradient fills for bar charts?

2008-03-18 Thread Chris Withers
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

Re: [Matplotlib-users] Gappy bars when no edge specified?

2008-03-18 Thread Chris Withers
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

Re: [Matplotlib-users] plotting with missing data?

2008-03-17 Thread Chris Withers
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,

[Matplotlib-users] placing legend outside of plot area

2008-03-17 Thread Chris Withers
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

Re: [Matplotlib-users] placing legend outside of plot area

2008-03-17 Thread Chris Withers
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),

Re: [Matplotlib-users] how to remove an xlabel?

2008-03-17 Thread Chris Withers
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

Re: [Matplotlib-users] placing legend outside of plot area

2008-03-17 Thread Chris Withers
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

Re: [Matplotlib-users] visualisation for utility usage sought

2008-03-14 Thread Chris Withers
(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

[Matplotlib-users] plotting with missing data?

2008-03-14 Thread Chris Withers
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

Re: [Matplotlib-users] Export plot to Word

2008-03-13 Thread Chris Withers
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

Re: [Matplotlib-users] [newbie] live plots of multiple lines

2008-03-11 Thread Chris Withers
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

Re: [Matplotlib-users] [newbie] live plots of multiple lines

2008-03-11 Thread Chris Withers
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

Re: [Matplotlib-users] [newbie] live plots of multiple lines

2008-03-11 Thread Chris Withers
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,

Re: [Matplotlib-users] [newbie] live plots of multiple lines

2008-03-11 Thread Chris Withers
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

[Matplotlib-users] [newbie] live plots of multiple lines

2008-03-07 Thread Chris Withers
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