Re: [Matplotlib-users] dates for x-axis

2012-04-18 Thread questions anon
I am not exactly sure how to use datetime objects instead of strings.
This is the code I am working with at the moment and the code works except
for the dates, they are just weird numbers along the x-axis.
Any help will be greatly appreciated.

import numpy as np
import matplotlib.pyplot as plt
from numpy import ma as MA
from mpl_toolkits.basemap import Basemap
from datetime import datetime
import os
from osgeo import gdal, gdalnumeric, ogr, osr
import glob
from datetime import date, timedelta
import matplotlib.dates as mdates
import time

rainmax=[]
yearmonthlist=[]
yearmonth_int=[]

OutputFolder=rE:/test_out/
GLOBTEMPLATE = re:/Rainfall/rainfall-{year}/r{year}{month:02}??.txt

def accumulate_month(year, month):
files = glob.glob(GLOBTEMPLATE.format(year=year, month=month))
monthlyrain=[]
monthlyrainaust=[]
for ifile in files:
f=np.genfromtxt(ifile,skip_header=6)
monthlyrain.append(f)
yearmonth=str(year)+str(month)
d=datetime.strptime(yearmonth, '%Y%m')
date_string=d.strftime('%Y%m')
yearmonthint=int(date_string)
yearmonth_int.append(yearmonthint)
yearmonthlist.append(yearmonth)
r_max=np.max(monthlyrain)
rainmax.append(r_max)


###loop through months and years
stop_month = datetime(2011, 04, 01)
month = datetime(2011, 01, 01)
while month  stop_month:
accumulate_month(month.year, month.month)
month += timedelta(days=32)
month = month.replace(day=01)


x=yearmonthlist
y=rainmax
x2=yearmonth_int

print x, y, x2

fig, ax=plt.subplots(1)

z=np.polyfit(x2,y,1)
p=np.poly1d(z)

plt.plot(x,y)
plt.plot(x,p(x2),'r--') #add trendline to plot
print y=%.6fx+(%.6f)%(z[0],z[1])

fig.autofmt_xdate()
ax.fmt_xdata=mdates.DateFormatter('%Y%m')
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y%m'))

plt.xlabel(year-month)
plt.ylabel(Precipitation (mm))
plt.title(Max monthly Precipition)
plt.savefig(OutputFolder+MaxMonthlyPrecip.png)
plt.show()





On Fri, Apr 13, 2012 at 2:31 AM, Goyo goyod...@gmail.com wrote:

 El día 12 de abril de 2012 03:46, questions anon
 questions.a...@gmail.com escribió:

  I am not sure how to recognise that x-axis are dates like 20110101,
  20110102, 20110103 etc.

 Use datetime objects instead of strings.

 Goyo

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] how to set scatter plot point size after drawing the plot?

2012-04-18 Thread Chao YUE
Dear all,

I draw a scatter plot.

it returns matplotlib.collections.PathCollection object. then how can I set
the size of the markers?
for a matplotlib.lines.Line2D object, there is a method set_markersize
which can be used to set markersize.
but no such method for matplotlib.collections.PathCollection object?

thanks et cheers,

Chao

-- 
***
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] install/link matplotlib backend in parallel python version

2012-04-18 Thread Naljer

Hi,

I would like to use the pre-installed backends like TKAgg an so on

with python2.7.

My standard-python is 2.6 and python 2.7 doesnt find the backends.

python2.7:
import matplotlib
matplotlib.use('TkAgg') 
from pylab import *

error something like: no tkinter installed

Please help! :-)
-- 
View this message in context: 
http://old.nabble.com/install-link-matplotlib-backend-in-parallel-python-version-tp33707166p33707166.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 0.99.1 crashes python on Windows XP [SEC=UNCLASSIFIED]

2012-04-18 Thread Werner F. Bruhin
On 18/02/2010 22:41, Werner F. Bruhin wrote:
 Using numpy with /arch nosse solved the issue.

 Probably OT here, but does anyone know if numpy will in the future be
 able to dynamically switch on/off the SSEx support?
I am running again into crashes with matplotlib/numpy on Windows XP 
running on AMD Athlon type machiens.

I distribute the application with py2exe, so on my machine I install 
numpy with /arch nosse.

This works on a test machine with my older program version which uses 
Python 2.5, matplotlib 0.99 and numpy 1.0.4, now with my newer stuff I 
use Python 2.6, still matplotlib 0.99 and numpy 1.3 (as there is no 
1.0.4 for Py 2.6), with this configuration my program crashes on the 
Athlon CPU.

Tried upgrading to 1.4.1 and 1.5.1 of numpy (still using /arch nosse) 
but still see the same crash with an error code of 0xc01d.

Short term a 1.0.4 for Python 2.6 would be an o.k. work around, but I 
really like to get a something better.  Would an upgrade of matplotlib help?

Werner

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 0.99.1 crashes python on Windows XP [SEC=UNCLASSIFIED]

2012-04-18 Thread francesco oteri
Hi Werner

Il giorno 18 aprile 2012 16:00, Werner F. Bruhin werner.bru...@free.fr ha
scritto:

 On 18/02/2010 22:41, Werner F. Bruhin wrote:
  Using numpy with /arch nosse solved the issue.
 
  Probably OT here, but does anyone know if numpy will in the future be
  able to dynamically switch on/off the SSEx support?
 I am running again into crashes with matplotlib/numpy on Windows XP
 running on AMD Athlon type machiens.

 I distribute the application with py2exe, so on my machine I install
 numpy with /arch nosse.

 This works on a test machine with my older program version which uses
 Python 2.5, matplotlib 0.99 and numpy 1.0.4, now with my newer stuff I
 use Python 2.6, still matplotlib 0.99 and numpy 1.3 (as there is no
 1.0.4 for Py 2.6), with this configuration my program crashes on the
 Athlon CPU.

 Tried upgrading to 1.4.1 and 1.5.1 of numpy (still using /arch nosse)
 but still see the same crash with an error code of 0xc01d.

 Short term a 1.0.4 for Python 2.6 would be an o.k. work around, but I
 really like to get a something better.  Would an upgrade of matplotlib
 help?


Usually upgrading your software helps! :)



 Werner


 --
 Better than sec? Nothing is better than sec when it comes to
 monitoring Big Data applications. Try Boundary one-second
 resolution app monitoring today. Free.
 http://p.sf.net/sfu/Boundary-dev2dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users




-- 
Cordiali saluti, Dr.Oteri Francesco
--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Plot data for a 24 by 16 array of subplots and allow zooming into any one of them.

2012-04-18 Thread hari jayaram
Hi
I am fairly new to matplotlib.

I have 384 x,y plots that I want to arrange into a 24 by 16 array of
subplots with each subplot being at-least 4 inches by 4 inches.

I am creating the figure using  a large size so that everything will fit

fig = plt.figure(figsize=(96,64),dpi=72)

I then have my for loop go through my data-structure and add the
subplots to this figure. In addition , each subplot has four
data-ranges plotted into it.

ax = fig.add_subplot(24,16,index + 1)
par1 = ax.twinx()
par2 = ax.twinx()
par3 = ax.twinx()
par4 = ax.twinx()
par1.plot(xs,ys,o,xcalc,ycalc)
par2.plot(xcalc,my_derivative,color=black)
par4.plot(xcalc,my_unsmooth_derivative,color=cyan)

In the present form I create a one pane window that shows all 384
plots and then navigate between the plots using pan.

My question is : Is there a more elegant way to do this? . Is there a
way instead to create a small shrunken down figure and then zoom in
one cell at a time?. The figure navigation controls only zoom with
respect to an axes. Is there a way to zoom w.r.t the whole figure
interactively.


Thanks for your help

Hari

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 0.99.1 crashes python on Windows XP [SEC=UNCLASSIFIED]

2012-04-18 Thread Benjamin Root
On Wed, Apr 18, 2012 at 10:00 AM, Werner F. Bruhin werner.bru...@free.frwrote:

 On 18/02/2010 22:41, Werner F. Bruhin wrote:
  Using numpy with /arch nosse solved the issue.
 
  Probably OT here, but does anyone know if numpy will in the future be
  able to dynamically switch on/off the SSEx support?
 I am running again into crashes with matplotlib/numpy on Windows XP
 running on AMD Athlon type machiens.

 I distribute the application with py2exe, so on my machine I install
 numpy with /arch nosse.

 This works on a test machine with my older program version which uses
 Python 2.5, matplotlib 0.99 and numpy 1.0.4, now with my newer stuff I
 use Python 2.6, still matplotlib 0.99 and numpy 1.3 (as there is no
 1.0.4 for Py 2.6), with this configuration my program crashes on the
 Athlon CPU.

 Tried upgrading to 1.4.1 and 1.5.1 of numpy (still using /arch nosse)
 but still see the same crash with an error code of 0xc01d.

 Short term a 1.0.4 for Python 2.6 would be an o.k. work around, but I
 really like to get a something better.  Would an upgrade of matplotlib
 help?

 Werner


I think we have some confusion for version numbers.  There was never a
version 1.0.4 of mpl.  There was a version 1.0.1, but not 1.0.4.  Also, you
mention numpy version 1.0.4, I certainly would hope you are referring to
numpy 1.4.0.  Could you please double-check your version numbers so we can
get a better idea of what is happening?

Thanks,
Ben Root
--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] 0.99.1 crashes python on Windows XP [SEC=UNCLASSIFIED]

2012-04-18 Thread Christoph Gohlke


On 4/18/2012 7:00 AM, Werner F. Bruhin wrote:
 On 18/02/2010 22:41, Werner F. Bruhin wrote:
 Using numpy with /arch nosse solved the issue.

 Probably OT here, but does anyone know if numpy will in the future be
 able to dynamically switch on/off the SSEx support?
 I am running again into crashes with matplotlib/numpy on Windows XP
 running on AMD Athlon type machiens.

 I distribute the application with py2exe, so on my machine I install
 numpy with /arch nosse.

 This works on a test machine with my older program version which uses
 Python 2.5, matplotlib 0.99 and numpy 1.0.4, now with my newer stuff I
 use Python 2.6, still matplotlib 0.99 and numpy 1.3 (as there is no
 1.0.4 for Py 2.6), with this configuration my program crashes on the
 Athlon CPU.

 Tried upgrading to 1.4.1 and 1.5.1 of numpy (still using /arch nosse)
 but still see the same crash with an error code of 0xc01d.

 Short term a 1.0.4 for Python 2.6 would be an o.k. work around, but I
 really like to get a something better.  Would an upgrade of matplotlib help?

 Werner


matplotlib-0.99.3.win32-py2.6 should work with 
numpy-1.4.1-win32-superpack-python2.6.exe

There was a bug prior to 0.99.2 (IIRC) that would crash on older Pentium 
computers.

If matplotlib-0.99.3 does crash with numpy-1.4.1, please send a small 
script and let us know exactly where and in which module it crashes, and 
the capabilities/model of your processor.

If possible, upgrade to numpy 1.6.1 and matplotlib 1.1.

Christoph

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Plot data for a 24 by 16 array of subplots and allow zooming into any one of them.

2012-04-18 Thread Benjamin Root
On Wed, Apr 18, 2012 at 12:40 PM, hari jayaram hari...@gmail.com wrote:

 Hi
 I am fairly new to matplotlib.

 I have 384 x,y plots that I want to arrange into a 24 by 16 array of
 subplots with each subplot being at-least 4 inches by 4 inches.

 I am creating the figure using  a large size so that everything will fit

 fig = plt.figure(figsize=(96,64),dpi=72)

 I then have my for loop go through my data-structure and add the
 subplots to this figure. In addition , each subplot has four
 data-ranges plotted into it.

 ax = fig.add_subplot(24,16,index + 1)
 par1 = ax.twinx()
 par2 = ax.twinx()
 par3 = ax.twinx()
 par4 = ax.twinx()
 par1.plot(xs,ys,o,xcalc,ycalc)
 par2.plot(xcalc,my_derivative,color=black)
 par4.plot(xcalc,my_unsmooth_derivative,color=cyan)

 In the present form I create a one pane window that shows all 384
 plots and then navigate between the plots using pan.

 My question is : Is there a more elegant way to do this? . Is there a
 way instead to create a small shrunken down figure and then zoom in
 one cell at a time?. The figure navigation controls only zoom with
 respect to an axes. Is there a way to zoom w.r.t the whole figure
 interactively.


 Thanks for your help

 Hari


mpl_toolkits.axes_grid1 can allow you to share all of the axes.  All x
and y lims will be the same and any change to one will reflect everywhere
else.  Does that help?

Ben Root
--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Stem 3d

2012-04-18 Thread José Alexandre Nalon
Hello,

I need to plot 2d sequences of two kinds. I wanted them to look like
a stem plot because of other plots that are in the same text.

There are actually two kinds of plots that I need: one is a standard
two-dimensional domain, with points in the domain over a rectangular
grid; the other is a two-variable function of one independent variable:
I need this to plot complex-sequences, with the markers around a
baseline.

If I couldn't make myself clear, the first one is like the image in
the link below:

http://www.mathworks.com/help/techdoc/ref/stem3.html

I couldn't find a link to an image similar to the second kind, though.
But this one is less important, as I can plot real and imaginary parts
in different axes.

I could get something that looked ok using scatter3d. If there is a
way to emulate the stem behaviour using that, I think it is ok. But
I thought that probably there is a better way to do it. Any help is
appreciated.

-- 
José Alexandre Nalon
na...@terra.com.br

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Stem 3d

2012-04-18 Thread Benjamin Root
On Wed, Apr 18, 2012 at 2:41 PM, José Alexandre Nalon na...@terra.com.brwrote:

 Hello,

 I need to plot 2d sequences of two kinds. I wanted them to look like
 a stem plot because of other plots that are in the same text.

 There are actually two kinds of plots that I need: one is a standard
 two-dimensional domain, with points in the domain over a rectangular
 grid; the other is a two-variable function of one independent variable:
 I need this to plot complex-sequences, with the markers around a
 baseline.

 If I couldn't make myself clear, the first one is like the image in
 the link below:

 http://www.mathworks.com/help/techdoc/ref/stem3.html

 I couldn't find a link to an image similar to the second kind, though.
 But this one is less important, as I can plot real and imaginary parts
 in different axes.

 I could get something that looked ok using scatter3d. If there is a
 way to emulate the stem behaviour using that, I think it is ok. But
 I thought that probably there is a better way to do it. Any help is
 appreciated.


There is not something that exists right now to do that, but there isn't
anything preventing that from being made except not having time to make
it.  Just as a rough outline of how I would approach it would be to take
the output of the 2d stem function, break it down into the constituent
parts (multiple collections there, I think), and pass them through the
appropriate 2d_to_3d functions that are available in art3d.py (I think that
is the right file).  This is the general idea for many of the current
mplot3d functions.  the 2d_to_3d conversion step is what adds third
dimension information.

Feel free to add a feature request to github.  I know I already have a long
list there, but in a few weeks I should be able to hack at them again and
that list is what will help me remember what needs to be done.

Oh, and of course, patches are always welcomed!  Even if it is incomplete,
I could take it as a starting point and clean it up.

Cheers!
Ben Root
--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Stem 3d

2012-04-18 Thread Benjamin Root
On Wed, Apr 18, 2012 at 3:27 PM, José Alexandre Nalon na...@terra.com.brwrote:

 Hello,


  Feel free to add a feature request to github.  I know I already have a
 long list there, but in a few weeks I should be able to hack at them
 again and that list is what will help me remember what needs to be done.

 Oh, and of course, patches are always welcomed!  Even if it is
 incomplete, I could take it as a starting point and clean it up.


 Ben, thanks for your answer. I don't have experience enough with a
 project with the size of matplotlib to put my hands in it without
 guidance; however, if you are willing to help me through the process,
 I can try to make a patch, and I might be able to help in the future.

 If you can direct me to a function you implemented that used the
 approach you suggested, I will try to understand the code and
 implement it. If it is good enough, I will submit a patch.

 Thanks again.



Jose,

Here is an example of how PolyCollection is converted into 3D:

http://matplotlib.sourceforge.net/examples/mplot3d/polys3d_demo.html

Of course, stem() doesn't create poly collections (I am actually not sure
what it creates), but it is likely that art3d has a converter for it.
Note, not all 2d collections and artists have converters.

Does that help?
Ben Root
--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Error autoscaling histogram with histtype='step'

2012-04-18 Thread Joshua Lande
I am running into problems where histograms are not autoscaling correctly.

I have filed a bug report on github:
https://github.com/matplotlib/matplotlib/issues/841

Below is a copy of the github bug report:

---

I am running into problems where histograms are not autoscaling correctly.

Below is a very simple example which reproduces this problem:

```
import pylab as P
P.hist([3000,3010, 3012], histtype='step')
P.savefig('test.pdf')
```

When I run this example using matplotlib v1.1.0 or using the absolute
latest version of matplotlib, I obtain an axes which varies from
3000x3012 and 0y3000 with no visible histogram.

When I add (before saving the plot) the line:
```
P.gca().set_ylim(ymax=2.1)
```
I get a reasonable axes range and can see the histogram.

I also get a reasonable axes range when I remove the command
histtype='step' or when I use matplotlib v1.0.0.

Thanks for your help,

Joshua

--
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second 
resolution app monitoring today. Free.
http://p.sf.net/sfu/Boundary-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] dates for x-axis

2012-04-18 Thread questions anon
Thank you, I was able to get it to work but only if I imported datetime
within the loop, otherwise I ended up with the
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'
and if I added 'import datetime' at the top of my script it had an error
where I loop through combining each month
stop_month = datetime(2011, 03, 01)
TypeError: 'module' object is not callable
It seems very messy with importing datetime everywhere but I am not sure
what the problem is. Below is the code I am using that works:


import numpy as np
import matplotlib.pyplot as plt
from numpy import ma as MA
from mpl_toolkits.basemap import Basemap
from datetime import datetime
import os
from StringIO import StringIO
from osgeo import gdal, gdalnumeric, ogr, osr
import glob
from datetime import date, timedelta
import matplotlib.dates as mdates
import time

rainmax=[]
rainmin=[]
rainmean=[]
yearmonthlist=[]
yearmonth_int=[]

OutputFolder=rE:/test_out/
GLOBTEMPLATE = re:/Rainfall/rainfall-{year}/r{year}{month:02}??.txt

def accumulate_month(year, month):
files = glob.glob(GLOBTEMPLATE.format(year=year, month=month))
monthlyrain=[]
for ifile in files:
f=np.genfromtxt(ifile,skip_header=6)
monthlyrain.append(f)

import datetime
yearmonth=datetime.datetime(year,month,1)
yearmonthlist.append(yearmonth)
yearmonthint=str(year)+str(month)
from datetime import date, datetime
d=datetime.strptime(yearmonthint, '%Y%m')
date_string=d.strftime('%Y%m')
yearmonthint=int(date_string)
yearmonth_int.append(yearmonthint)
r_max, r_mean, r_min=MA.max(monthlyrain), MA.mean(monthlyrain),
MA.min(monthlyrain)
rainmax.append(r_max)
rainmean.append(r_mean)
rainmin.append(r_min)


###loop through months and years
stop_month = datetime(2011, 12, 31)
month = datetime(2011, 01, 01)
while month  stop_month:
accumulate_month(month.year, month.month)
month += timedelta(days=32)
month = month.replace(day=01)


### Plot timeseries of max data
x=yearmonthlist
y=rainmax
x2=yearmonth_int

print x, y, x2

fig, ax=plt.subplots(1)

z=np.polyfit(x2,y,1)
p=np.poly1d(z)

plt.plot(x,y)
plt.plot(x,p(x2),'r--') #add trendline to plot
print y=%.6fx+(%.6f)%(z[0],z[1])

fig.autofmt_xdate()
ax.fmt_xdata=mdates.DateFormatter('%Y%m')
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y%m'))

plt.xlabel(year-month)
plt.ylabel(Precipitation (mm))
plt.title(Max monthly precipition)
plt.savefig(OutputFolder+MaxMonthlyPrecip.png)
plt.show()




On Thu, Apr 19, 2012 at 2:52 AM, Goyo goyod...@gmail.com wrote:

 El día 18 de abril de 2012 07:59, questions anon
 questions.a...@gmail.com escribió:
  I am not exactly sure how to use datetime objects instead of strings.
  This is the code I am working with at the moment and the code works
 except
  for the dates, they are just weird numbers along the x-axis.

 Seems like you're plotting yearmonthlist in the x axis, which is a
 list of strings and each string is the concatenation of the string
 representations of two numbers. So numbers in the x axis are to be
 expected.

 You can create datetime objects this way:

 d = datetime.datetime(year, month, 1)

 Then create an array of datetime objects and use it as the x parameter to
 plot.

 Goyo

--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Bug in legend?

2012-04-18 Thread Jae-Joon Lee
Handling alpha can become very tricky with matplotlib.
The problem is not specific for legend thing, but how attribute of
patches are updated when the update_from method is called.
Here is an example.


  from matplotlib.patches import Patch

  pa1 = Patch(alpha=None, fc='none', ec='b')
  pb1 = Patch(alpha=1, fc='none', ec='b')

  pa2 = Patch()
  pb2 = Patch()

  pa2.update_from(pa1)
  pb2.update_from(pb1)

  assert pa1.get_fc() == pa2.get_fc()
  assert pb1.get_fc() == pb2.get_fc()

And the second assertion fails.
fc=none sets facecolor to (0,0,0,0) but when update_from is called,
somehow its alpha value is overridden to 1 (because of alpha=1).
This seems to be a bug and maybe we need to tweak the update_from
method to get it right. But others may think differently. I'll file an
issue with it.

Meanwhile, please explicitly set fill=False to avoid filling. e.g.,

  ax.fill(y,x, label='alpha=1', alpha=0.5, fc='none', ec='r', fill=False)

Regards,

-JJ




On Tue, Apr 17, 2012 at 12:49 AM, Paul Hobson pmhob...@gmail.com wrote:
 On Mon, Apr 16, 2012 at 4:58 AM, Yannick Copin
 yannick.co...@laposte.net wrote:
 Hi List,

 I think I found a bug in legend of a fill command (see attached code and
 figure) when the facecolor is 'none' but the alpha is not None (I'm using
 latest matplotlib 1.1.0). If confirmed, should I fill in a but report?

 I see identical behavior in Christoph Gohlke's Windows build of
 Matplotlib 1.2.X for Python 3.2.

 The same thing occurs if you remove the alpha=None altogether.
 -paul

 --
 For Developers, A Lot Can Happen In A Second.
 Boundary is the first to Know...and Tell You.
 Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
 http://p.sf.net/sfu/Boundary-d2dvs2
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users