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

2008-03-28 Thread Matthias Michler
Hello Chris,
Hello list,

On Thursday 27 March 2008 18:26, Chris Withers wrote:
 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?

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)

 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.  
e.g. errobar (from the docstring) 
Return value is a length 3 tuple.  The first element is the
Line2D instance for the y symbol lines.  The second element is
a list of error bar cap lines, the third element is a list of
line collections for the horizontal and vertical error ranges
I think it is quite expensive to reset all x/ydata of the lines by yourself 
and I have no idea how to reset data of line collections.

I would replot the errorbars, but maybe somebody else knows a good way to 
reset the data of errorbars.

regards 
Matthias

-
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] prctile not interpolating

2008-03-28 Thread Lionel Roubeyrie
You can use the scipy version:
|~|[10]from scipy.stats import stats
|~|[11]stats.scoreatpercentile(x,50)
Out [11]:7.5

Le vendredi 28 mars 2008, David Simpson a écrit :
 I would like to find percentiles, with interpolation where needed, but
 the matplotlib prctile seems to be different to matlab in this respect:

 In [1]: x = array([ 3.0, 5.0, 7.0, 8.0, 9.0, 11.0 ])

 In [2]: median(x)
 Out[2]: 7.5

 In [3]: prctile(x,50)
 Out[3]: 8.0


 is there a function available which does include interpolation, or
 should I just write my own? (I'd also like 10th and 90th percentiles for
 example).

 Thanks, Dave

 -
 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/marketplac
e ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



-- 
Lionel Roubeyrie - [EMAIL PROTECTED]
Chargé d'études et de maintenance
LIMAIR - la Surveillance de l'Air en Limousin
http://www.limair.asso.fr


-
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

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 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

2008-03-28 Thread Matthias Michler
On Friday 28 March 2008 13:57, Chris Withers wrote:
 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...

At least I don't know a better way, but I'm not an expert.

  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?

Scatter returns a line collection and I don't know if there is a method to 
reset their x/ydata.

 For bar charts and errorbar plots, I agree ;-) How would I just blank
 the figure and replot?
I'm not sure, but maybe clf() to clear the whole figure and cla() to clear the 
axes does the job.
 (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)

regards,
Matthias

-
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] Polygon masking possible?

2008-03-28 Thread Chiara Caronna

I am not sure how should I use it any hints?

 From: [EMAIL PROTECTED]
 To: matplotlib-users@lists.sourceforge.net
 Subject: Re: [Matplotlib-users] Polygon masking possible?
 Date: Fri, 14 Mar 2008 18:03:13 +
 CC: [EMAIL PROTECTED]
 
 On Friday 14 March 2008 16:44:54 Chiara Caronna wrote:
 I tried ds9 and It looks like this is what I would like to do (though I
 couldn't try funtools, but what you describe is good). DO you think it is
 possible to make something like this with matplotlib? Thanks a lot for your
 
 The initiating thread (from January) had some suggestions. In particular, 
 some 
 code that does this from Rob Hetland: 
 
 
 Hope that helps,
 Jose

_
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vistamkt=en-USform=QBRE
-
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

2008-03-28 Thread John Hunter
On Fri, Mar 28, 2008 at 8:20 AM, Matthias Michler
[EMAIL PROTECTED] wrote:
 On Friday 28 March 2008 13:57, Chris Withers wrote:
   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...

  At least I don't know a better way, but I'm not an expert.


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?

  Scatter returns a line collection and I don't know if there is a method to
  reset their x/ydata.

We do not have good built in support for this kind of thing (though we
should add it).  One approach is to write a custom artist, as in this
example.  I'm using GTK only for the idle handling callback, but you
can use whatever approach works for you.  The important part is the
example showing how to write a custom artist for dynamic data:

import gtk
import numpy as np

import matplotlib
matplotlib.use('GTKAgg')
import matplotlib.pyplot as plt
import matplotlib.artist as artist
import matplotlib.colors as colors
import matplotlib.agg as agg

class DynamicMarkers(artist.Artist):
def __init__(self, buffersize=30):
artist.Artist.__init__(self)
self.buffersize = buffersize
self.x = []
self.y = []
self.count = 0
self.path = None
self.markersize = 10.
self.facecolor = colors.colorConverter.to_rgb('blue')
self.edgecolor = colors.colorConverter.to_rgb('black')

def add(self, x, y):
self.count+=1
self.x.append(x)
self.y.append(y)
if self.countself.buffersize:
del self.x[0]
del self.y[0]

def draw(self, renderer):
if self.axes is None:
raise RuntimeError('you must first add me to the axes')

if self.path is None:
# use square markers
side = renderer.points_to_pixels(self.markersize)
offset = side*0.5

path = agg.path_storage()
path.move_to(-offset, -offset)
path.line_to(-offset, offset)
path.line_to(offset, offset)
path.line_to(offset, -offset)
path.end_poly()
self.path = path

gc = renderer.new_gc()
self._set_gc_clip(gc)  # Artist method
gc.set_foreground(self.edgecolor)

renderer.draw_markers(gc, self.path, self.facecolor, self.x,
self.y, self.get_transform())


fig = plt.figure()
ax = fig.add_subplot(111)
myline = DynamicMarkers(30)
ax.add_artist(myline)
ax.set_xlim(-20, 1)

ax.set_ylim(0,1)

def animate(*args):

i = animate.i
print 'animate', i
myline.add(i, np.random.rand())
ax.set_xlim(i-30, i+1)
fig.canvas.draw()
animate.i += 1

if animate.i200: return True
else: return False


gtk.idle_add(animate)
animate.i = 0


plt.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] Setting font family in ticks not possible. Bug?

2008-03-28 Thread Gerolf Ziegenhain
More complete:

I tried all permunations of backends. Now I stick to PS, because I use
matplotlib from commandline with scripts. The environment is debian/etch
with a current version of matplotlib (self compiled).

Try this script

from pylab import *

t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s)
grid(True)

# matlab handle graphics style
xticklines = getp(gca(), 'xticklines')
yticklines = getp(gca(), 'yticklines')
xgridlines = getp(gca(), 'xgridlines')
ygridlines = getp(gca(), 'ygridlines')
xticklabels = getp(gca(), 'xticklabels')
yticklabels = getp(gca(), 'yticklabels')

setp(xticklines, 'linewidth', 3)
setp(yticklines, 'linewidth', 3)
setp(xgridlines, 'linestyle', '-')
setp(ygridlines, 'linestyle', '-')
setp(yticklabels, 'color', 'r', fontsize='medium')
setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif')

savefig('axprops_demo')
**

On my system the line
  setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif')
doesn't change the font family.

Best regards:
  Gerolf



-- 
Dipl. Phys. Gerolf Ziegenhain ([EMAIL PROTECTED])
Private: Klopstockstrasse 21 - 65187 Wiesbaden - Germany
Office: Room 46-332 - Erwin-Schrödinger-Str.46 - TU Kaiserslautern - Germany
Web: gerolf.ziegenhain.com
Tel.: +49-611-18840590
Fax: +49-611-18840599
-
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] Setting font family in ticks not possible. Bug?

2008-03-28 Thread Gerolf Ziegenhain
Hi,

Thanks for all the replies! Of course it is not directly a bug. But
awkward. This is how I was finally able to change alle fonts and the
whole layout of the plot:

fig_width_pt = 246.0  # Get this from LaTeX using \showthe\columnwidth
inches_per_pt = 1.0/72.27   # Convert pt to inch
golden_mean = (sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt  # width in inches
fig_height = fig_width*golden_mean  # height in inches
fig_size =  [fig_width,fig_height]
params = {'backend': 'ps','axes.labelsize': 10,'text.fontsize': 
10,'legend.fontsize': 10,'text.usetex': 
True,'text.latex.preamble':[\usepackage{bm},\usepackage{textcomp}], 
'figure.figsize': fig_size, 'font.family' : 'sans-serif', 'font.style': 
'normal', 'font.weight':'normal',}
rcParams.update(params)

...

ffont = {'family':'sans-serif','fontsize':10,'weight':'bold'}
ax1=gca()
ax1.set_xticklabels(ax1.get_xticks(),ffont)
ax1.set_yticklabels(ax1.get_yticks(),ffont)
subplots_adjust(top=1-.13)
xticks(**ffont)
yticks(**ffont)

Best regards:
   Gerolf

On Thu 27.Mar.08 14:54, Darren Dale wrote:
 On Thursday 27 March 2008 01:27:28 pm Gerolf Ziegenhain wrote:
  More complete:
 
  I tried all permunations of backends. Now I stick to PS, because I use
  matplotlib from commandline with scripts. The environment is debian/etch
  with a current version of matplotlib (self compiled).
 
  Try this script
  
  from pylab import *
 
  t = arange(0.0, 2.0, 0.01)
  s = sin(2*pi*t)
  plot(t, s)
  grid(True)
 
  # matlab handle graphics style
  xticklines = getp(gca(), 'xticklines')
  yticklines = getp(gca(), 'yticklines')
  xgridlines = getp(gca(), 'xgridlines')
  ygridlines = getp(gca(), 'ygridlines')
  xticklabels = getp(gca(), 'xticklabels')
  yticklabels = getp(gca(), 'yticklabels')
 
  setp(xticklines, 'linewidth', 3)
  setp(yticklines, 'linewidth', 3)
  setp(xgridlines, 'linestyle', '-')
  setp(ygridlines, 'linestyle', '-')
  setp(yticklabels, 'color', 'r', fontsize='medium')
  setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif')
 
  savefig('axprops_demo')
  **
 
  On my system the line
   setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif')
  doesn't change the font family.
 
 Do you use usetex? If you do, the mathtext is rendered using latex, and 
 latex renders mathtext in serif fonts.
 
 Darren
 
 -
 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

-- 
Dipl. Phys. Gerolf Ziegenhain 
Web: http://gerolf.ziegenhain.com
Email:   [EMAIL PROTECTED]
Fax: +49 611 18840599
Phone:   +49 611 18840590
Office:  Erwin-Schrödinger-Str. 46 / Room 46.332 / 67663 Kaiserslautern / 
Germany
Private: Klopstockstr. 21 / 65187 Wiesbaden / Germany

-
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


[Matplotlib-users] wxagg back-end bug on windows?

2008-03-28 Thread Chris Barker
Hi all,

I'm having an odd issue with the wxAgg back-end:

windows XP
python 2.5.2 (from python.org)
wxPython 2.8.7.1 unicode (binary from wxPython.org)
MPL 0.91.2 (binary from MPl site)

when I run:
import matplotlib
matplotlib.use('wxagg')
import pylab

I get a popup dialog:

This application failed to start  because wxmsw26uh_vc.dll was not found

It looks like it is looking for a wxPython2.6 dll, which it doesn't 
find, because I'm running wxPython2.8

I'm guessing this binary was compiled against wxPython2.6, but I thought 
the current wxAgg back-end didn't try to use the accelerated module for 
wxPython2.8.

Any ideas?

By the way, there are a number of other small bugs cropping up in the 
pylab window with wxagg too -- but I'll look at those once I solve this.

Is no one else using MPL with wxPython2.8?

-Chris





-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/ORR(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

[EMAIL PROTECTED]

-
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] wxagg back-end bug on windows?

2008-03-28 Thread Chris Barker
Chris Barker wrote:
 Hi all,
 
 I'm having an odd issue with the wxAgg back-end:

Update:

If I remove:

matplotlib/backends/_wxagg.pyd

The problem goes away.

It looks like that pyd is getting loaded even though I'm running wxPython2.8

However, now I get a non-valid png when I do savefig


-Chris





-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/ORR(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

[EMAIL PROTECTED]

-
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