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

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

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 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] matplotlib threadsafe?

2008-03-19 Thread Michael Droettboom
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.  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.
Oh yes -- I didn't think of the rcParams.

 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.

 Possibly this could be changed.  The danger would be accidentally 
 modifying or deleting an array that is being used by C extension code.
Modifying may be problematic, but deleting would not be likely -- the C 
function holds a reference to each of the arrays as they are using them.


 However, I can't speak about this from any experience -- so, maybe it 
 needs some trying.  Any patches to help with thread safety and 
 performance are of course welcome ;)

 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.  Pyplot would then instantiate and use one of 
 these; the OO API would allow one to instantiate any number of them.  
 I have not thought about how easy or hard this would be.
Ditto that.  Having just come back from PyCon, I'll parrot the standard 
Python answer to this question which is: Don't use threads, use 
multiple processes, which would seem to solve all these issues -- but, 
I understand that it not always the best solution.

Mike

 Eric


 Cheers,
 Mike

 Chris Withers wrote:
 Hi All,

 I'm wondering what work people have done with matplotlib in 
 multi-threaded environments such as your average python web framework.

 Is matplotlib threadsafe?

 How have people gone about safely using it in a multi-threaded 
 environment?

 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


-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


-
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] Bug exporting mathtext to eps file in 0.91.2 on windows

2008-03-19 Thread Mark Bakker
I have confirmed that it is a bug in (at least the windows version) of mpl
0.91.2.
When saving eps files, and using mathtext, the cm fonts don't get saved, and
the
greek symbols (and others I presume) don't show up in the eps file.

This works in mpl 0.90.1, where the eps file does store the fonts.
%%BeginFont: Cmmi10

When running the same problem with 0.91.2, the fonts are not stored.
Either using ps.fonttype 3 or 42.

Anybody who can fix this?

Thanks, Mark

On Wed, Mar 19, 2008 at 11:21 AM, Bernhard Voigt [EMAIL PROTECTED]
wrote:

 Hi Mark!

 The problem seems to be that the computer modern font (cm) is not
 included in the eps file. The snipped of the eps file I sent before
 defines the font cmmi10:

 %!PS-Adobe-3.0 Resource-Font
 %%Title: cmmi10
 %%Copyright: Copyright (C) 1994, Basil K. Malyshev. All Rights
 Reserved.012BaKoMa Fonts Colle
 ction, Level-B.
 %%Creator: Converted from TrueType by PPR
 .
 /FontName /Cmmi10 def

 And later, when the \chi glyph should be drawn, the font is changed to:
 /Cmmi10 findfont
 16.0 scalefont
 setfont
 0.00 4.921875 moveto
 /chi glyphshow

 Which is the same in your file, but your file only contains the
 Bitstreem Vera Sans font for the axis ticks. Cmmi10 is missing :-(

 Your pdf, however, does contain the cmmi10 font, you can check via
 file-properties-fonts.

 You should have the following in your matplotlibrc file (well, you
 said you have it, but let me repeat):
 mathtext.fontset : cm
 mathtext.fallback_to_cm : True
 ps.useafm : False
 ps.fonttype : 3

 Check the settings using the interpreter prompt:

 In [10]: p.rcParams['mathtext.fontset']
 Out[10]: 'cm'
 etc...

 Well, if they are all correctly set, it's probably a bug in the ps
 backend not including the mathtext font.

 A workaround would be to convert the pdf file to ps (either use
 command line options of acroread or print to file), edit the ps file
 to be a eps by changing the header to %!PS-Adobe-2.0 EPSF-2.0 and make
 sure the bounding box is specified (see
 http://www.postscript.org/FAQs/language/node82.html for details)

 Bernhard


 On Wed, Mar 19, 2008 at 10:22 AM, Mark Bakker [EMAIL PROTECTED] wrote:
  Hello Mike -
 
  Thanks for taking a look at this.
  Easy example:
 
  from pylab import *
  plot([1,2,3])
  text(1,1.5,r'$\chi$')
  savefig('d:/temp/test.eps')
 
  There shoud now be a line and the symbol chi.
  Works great in the pdf file, not in the eps file.
  Both are attached.
 
  Strangely enough at the end of the eps file there are statements:
 
  0.00 3.703125 moveto
  /chi glyphshow
 
  Which looks to me like writing chi.
  I have now tried this on 4 windows machines, with different
 installations of gsview, but it doesn't work on any.
 
  It works fine under mpl vs. 0.90.1. That has the same statement for chi,
 but defines chi internally inside the eps file (which is much bigger).
 
  Thanks, Mark
 
 
 
 
 
 
 
  On Tue, Mar 18, 2008 at 7:09 PM, mdroe [EMAIL PROTECTED] wrote:
 
   It looks like it may be Windows-specific.  I can create .eps files
 with
   math on mpl-0.91.2, Python 2.5, gs-7.07 on Linux without problems.
   Someone with a Windows installation may need to look at this.
  
   Just so I can have a deeper look -- can you please attach
  
a) the Python source of a minimal plot that causes this problem
b) your .eps file output (so I can compare it against mine).
  
   Mike
  
 
 

-
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] Bug exporting mathtext to eps file in 0.91.2 on windows

2008-03-19 Thread Michael Droettboom
Unfortunately, I'm still unable to reproduce the problem myself.  Have 
you tried installing the CM fonts (copying them to C:\Windows\Fonts)?  
Maybe GS is trying to re-embed them and can't find them.

Cheers,
Mike

Mark Bakker wrote:
 I have confirmed that it is a bug in (at least the windows version) of 
 mpl 0.91.2.
 When saving eps files, and using mathtext, the cm fonts don't get 
 saved, and the
 greek symbols (and others I presume) don't show up in the eps file.

 This works in mpl 0.90.1, where the eps file does store the fonts.
 %%BeginFont: Cmmi10

 When running the same problem with 0.91.2, the fonts are not stored.
 Either using ps.fonttype 3 or 42.

 Anybody who can fix this?

 Thanks, Mark

 On Wed, Mar 19, 2008 at 11:21 AM, Bernhard Voigt 
 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:

 Hi Mark!

 The problem seems to be that the computer modern font (cm) is not
 included in the eps file. The snipped of the eps file I sent before
 defines the font cmmi10:

 %!PS-Adobe-3.0 Resource-Font
 %%Title: cmmi10
 %%Copyright: Copyright (C) 1994, Basil K. Malyshev. All Rights
 Reserved.012BaKoMa Fonts Colle
 ction, Level-B.
 %%Creator: Converted from TrueType by PPR
 .
 /FontName /Cmmi10 def

 And later, when the \chi glyph should be drawn, the font is
 changed to:
 /Cmmi10 findfont
 16.0 scalefont
 setfont
 0.00 4.921875 moveto
 /chi glyphshow

 Which is the same in your file, but your file only contains the
 Bitstreem Vera Sans font for the axis ticks. Cmmi10 is missing :-(

 Your pdf, however, does contain the cmmi10 font, you can check via
 file-properties-fonts.

 You should have the following in your matplotlibrc file (well, you
 said you have it, but let me repeat):
 mathtext.fontset : cm
 mathtext.fallback_to_cm : True
 ps.useafm : False
 ps.fonttype : 3

 Check the settings using the interpreter prompt:

 In [10]: p.rcParams['mathtext.fontset']
 Out[10]: 'cm'
 etc...

 Well, if they are all correctly set, it's probably a bug in the ps
 backend not including the mathtext font.

 A workaround would be to convert the pdf file to ps (either use
 command line options of acroread or print to file), edit the ps file
 to be a eps by changing the header to %!PS-Adobe-2.0 EPSF-2.0 and make
 sure the bounding box is specified (see
 http://www.postscript.org/FAQs/language/node82.html for details)

 Bernhard


 On Wed, Mar 19, 2008 at 10:22 AM, Mark Bakker [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:
  Hello Mike -
 
  Thanks for taking a look at this.
  Easy example:
 
  from pylab import *
  plot([1,2,3])
  text(1,1.5,r'$\chi$')
  savefig('d:/temp/test.eps')
 
  There shoud now be a line and the symbol chi.
  Works great in the pdf file, not in the eps file.
  Both are attached.
 
  Strangely enough at the end of the eps file there are statements:
 
  0.00 3.703125 moveto
  /chi glyphshow
 
  Which looks to me like writing chi.
  I have now tried this on 4 windows machines, with different
 installations of gsview, but it doesn't work on any.
 
  It works fine under mpl vs. 0.90.1. That has the same statement
 for chi, but defines chi internally inside the eps file (which is
 much bigger).
 
  Thanks, Mark
 
 
 
 
 
 
 
  On Tue, Mar 18, 2008 at 7:09 PM, mdroe [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:
 
   It looks like it may be Windows-specific.  I can create .eps
 files with
   math on mpl-0.91.2, Python 2.5, gs-7.07 on Linux without problems.
   Someone with a Windows installation may need to look at this.
  
   Just so I can have a deeper look -- can you please attach
  
a) the Python source of a minimal plot that causes this problem
b) your .eps file output (so I can compare it against mine).
  
   Mike
  
 
 



-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


-
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] Bug exporting mathtext to eps file in 0.91.2 on windows

2008-03-19 Thread John Hunter
On Wed, Mar 19, 2008 at 7:43 AM, Mark Bakker [EMAIL PROTECTED] wrote:
 I have confirmed that it is a bug in (at least the windows version) of mpl
 0.91.2.
 When saving eps files, and using mathtext, the cm fonts don't get saved, and
 the
 greek symbols (and others I presume) don't show up in the eps file.

 This works in mpl 0.90.1, where the eps file does store the fonts.
 %%BeginFont: Cmmi10

 When running the same problem with 0.91.2, the fonts are not stored.
 Either using ps.fonttype 3 or 42.

 Anybody who can fix this?

My guess is that you are picking up an rc file where useafm is set to
True.  Michael suggested checking this rc setting but I did not see
any response on this on list.  Have you checked it?  In the script
that is causing you trouble, print out the value

import matplotlib

print 'afm setting', matplotlib.rcParams['ps.useafm']

If this is True, then you need to find your matplotlibrc file and set
it to False.

I can't imagine a windows vs other platform issue that could cause
this since we do not use only matplotlib tools in our font conversion
pipeline

JDH

-
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] Bug exporting mathtext to eps file in 0.91.2 on windows

2008-03-19 Thread Mark Bakker
Sorry, John, but here is my output, and it still doesn't work.

 from pylab import *
 rcParams['mathtext.fontset']
'cm'
 rcParams['mathtext.fallback_to_cm']
True
 rcParams['ps.useafm']
False
 rcParams['ps.fonttype']
3
 plot([1,2,3])
[matplotlib.lines.Line2D instance at 0x029F0120]
 text(1,1.5,r'$\chi$')
matplotlib.text.Text instance at 0x029F6968
 savefig('c:/temp/test.eps')

On the same machine, I get the correct eps file with 0.90.1.
So it really isn't my installation of GsView.

In the eps file created with 0.91.2, the cm fonts are not included, which I
think is causing the problem.

What happens when you guys read the attached eps file (created with commands
above)?
Do you see the chi symbol on the screen?

Thanks for looking into this,

Mark


On Wed, Mar 19, 2008 at 2:18 PM, John Hunter [EMAIL PROTECTED] wrote:

 On Wed, Mar 19, 2008 at 7:43 AM, Mark Bakker [EMAIL PROTECTED] wrote:
  I have confirmed that it is a bug in (at least the windows version) of
 mpl
  0.91.2.
  When saving eps files, and using mathtext, the cm fonts don't get saved,
 and
  the
  greek symbols (and others I presume) don't show up in the eps file.
 
  This works in mpl 0.90.1, where the eps file does store the fonts.
  %%BeginFont: Cmmi10
 
  When running the same problem with 0.91.2, the fonts are not stored.
  Either using ps.fonttype 3 or 42.
 
  Anybody who can fix this?

 My guess is that you are picking up an rc file where useafm is set to
 True.  Michael suggested checking this rc setting but I did not see
 any response on this on list.  Have you checked it?  In the script
 that is causing you trouble, print out the value

 import matplotlib

 print 'afm setting', matplotlib.rcParams['ps.useafm']

 If this is True, then you need to find your matplotlibrc file and set
 it to False.

 I can't imagine a windows vs other platform issue that could cause
 this since we do not use only matplotlib tools in our font conversion
 pipeline

 JDH



test.eps
Description: PostScript document
-
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] Bug exporting mathtext to eps file in 0.91.2 on windows

2008-03-19 Thread Michael Droettboom
I don't see the character in the plot you sent.  So at least that's 
consistent.  ;)

However, I still can't get things to break locally (on Linux, at least), 
with all permutations of ps.fonttype, ps.useafm, ps.distiller, and 
mathtext.fontset.

Can you send your entire matplotlibrc file?  Perhaps there is some other 
obscure setting that's interacting in a negative way.

Mike

Mark Bakker wrote:
 Sorry, John, but here is my output, and it still doesn't work.

  from pylab import *
  rcParams['mathtext.fontset']
 'cm'
  rcParams['mathtext.fallback_to_cm']
 True
  rcParams['ps.useafm']
 False
  rcParams['ps.fonttype']
 3
  plot([1,2,3])
 [matplotlib.lines.Line2D instance at 0x029F0120]
  text(1,1.5,r'$\chi$')
 matplotlib.text.Text instance at 0x029F6968
  savefig('c:/temp/test.eps')

 On the same machine, I get the correct eps file with 0.90.1.
 So it really isn't my installation of GsView.

 In the eps file created with 0.91.2, the cm fonts are not included, 
 which I think is causing the problem.

 What happens when you guys read the attached eps file (created with 
 commands above)?
 Do you see the chi symbol on the screen?

 Thanks for looking into this,

 Mark


 On Wed, Mar 19, 2008 at 2:18 PM, John Hunter [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] wrote:

 On Wed, Mar 19, 2008 at 7:43 AM, Mark Bakker [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:
  I have confirmed that it is a bug in (at least the windows
 version) of mpl
  0.91.2.
  When saving eps files, and using mathtext, the cm fonts don't
 get saved, and
  the
  greek symbols (and others I presume) don't show up in the eps file.
 
  This works in mpl 0.90.1, where the eps file does store the fonts.
  %%BeginFont: Cmmi10
 
  When running the same problem with 0.91.2, the fonts are not stored.
  Either using ps.fonttype 3 or 42.
 
  Anybody who can fix this?

 My guess is that you are picking up an rc file where useafm is set to
 True.  Michael suggested checking this rc setting but I did not see
 any response on this on list.  Have you checked it?  In the script
 that is causing you trouble, print out the value

 import matplotlib

 print 'afm setting', matplotlib.rcParams['ps.useafm']

 If this is True, then you need to find your matplotlibrc file and set
 it to False.

 I can't imagine a windows vs other platform issue that could cause
 this since we do not use only matplotlib tools in our font conversion
 pipeline

 JDH



-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


-
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] Animation - Tk

2008-03-19 Thread Kenneth Miller

All,

   Alright I've made some progress here improving upon the example.  
(Codes at the bottom). So it looks like I've started a writing a  
wrapper class around the plot command that continuously updates it's  
data by itself without having to write extra code. To me, using the  
subplot commands like set_xdata and set_ydata, should automatically  
update the graph, as I really don't like dealing with that myself. So  
what's happening below is that I'm starting two threads along with the  
Tkinter user thread. The first thread watches for changes in the data  
and the second actually induces changes forever. I know that the way  
I'm doing all this is a) quick and dirty b) really bad c) un-pythonic  
and d) it closes off all the current methods to plot etc, which if I  
need to continue developing this, I'll open them up as well the best I  
can.


So that brings me to my next question. Is all this necessary? Is there  
a simpler way to make auto-updating graphs without all of the lines of  
outside code?


One last question, if anyone runs this, you'll notice that the graph  
stops updating whenever you use the menu, or move the tkinter window,  
does anyone have a clue to why this is?


Thank you to everyone for your time.

Regards,
Kenneth Miller

~~~START CODE

import sys
import pylab as p
import numpy as npy
import time
import Tkinter as Tk
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,  
NavigationToolbar2TkAgg


import threading

class SimplePlot:
   def __init__(self,root):



   f = matplotlib.figure.Figure(figsize=(5,4),dpi=100)
   self.ax = f.add_subplot(111)
   self.canvas = self.ax.figure.canvas


   # create the initial line

   canvas = FigureCanvasTkAgg(f, master=root)
   canvas.show()
   canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

   self.canvas = canvas

   toolbar = NavigationToolbar2TkAgg( canvas, root )
   toolbar.update()
   canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

   manager = p.get_current_fig_manager()
   manager.window.after(100, self.run)

   def plot(self,x,y):
   line, = p.plot(x,y,animated=True,lw=2)
   self.x = x
   self.y = y
   self.line = line




   def run(self,*args):


   class MyThread(threading.Thread):
   def __init__(self,simplePlot):
   self.simplePlot = simplePlot
   print dir(self)
   threading.Thread.__init__(self)
   def run(self):
   background =  
self.simplePlot.canvas.copy_from_bbox(self.simplePlot.ax.bbox)

   # for profiling
   tstart = time.time()
   self.cnt = 0
   while 1:
   # restore the clean slate background
   self.simplePlot.canvas.restore_region(background)
   # update the data
   self.simplePlot.line.set_ydata(self.simplePlot.y)
   # just draw the animated artist
   self.simplePlot.ax.draw_artist(self.simplePlot.line)
   # just redraw the axes rectangle
   self.simplePlot.canvas.blit(self.simplePlot.ax.bbox)

   if self.cnt==100:
   # print the timing info and quit
   print 'FPS:' , 100/(time.time()-tstart)
   self.cnt=0
   tstart = time.time()

   self.cnt += 1

   mt = MyThread(self)
   mt.start()


class DataThread(threading.Thread):
   def run(self):
   import time
   i = 0.0
   while 1:
   s.x = x
   s.y = npy.sin(x+i/10.0)
   time.sleep(0.01)
   i += 1.0

root = Tk.Tk()
root.wm_title(Embedding)

s = SimplePlot(root)

#some data points
x = npy.arange(0,2*npy.pi,0.01)
y = npy.sin(x)
s.plot(x,y)

dt = DataThread()
dt.start()

Tk.mainloop()

dt.join()

~~end code~
On Mar 14, 2008, at 12:46 PM, Kenneth Miller wrote:


All,

I've seen the examples for embedding matplot lib in Tk and the  
Tk animation example. However I've not yet been successful with  
creating an example where i can both animate data and stay in  
control of Tk. (The animation in tk example seems to lock the  
mainloop.) Does anyone have any advice or a quick example of a Tk  
app with an animated graph that doesn't lock the user out of Tk  
control?


Regards,
Kenneth Miller


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

2008-03-19 Thread Giorgio F. Gilestro

import numpy as np
a = ['','','',1.1,2.2]
mask_a = [i == '' for i in a]
b = np.ma.MaskedArray(a, mask=mask_a)



Chris Withers wrote:
 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

   


-- 
[EMAIL PROTECTED]
http://www.cafelamarck.it



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

2008-03-19 Thread Eric Firing
Chris,

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.  Support and 
integration are improving, but still far from perfect.  A largely new, 
and substantially different, implementation of masked arrays has been 
transplanted into numpy since the last release.  Similarly, mpl got a 
heart transplant since the last release, and it has some implications 
for the way nans and masked arrays are handled. There is lots more room 
for fundamental work on both numpy masked arrays (e.g., moving core code 
to pyrex/cython or C to speed them up) and on mpl.

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?  At the very least, additional 
arguments are needed to specify what should happen for fill-type 
plotting with missing values.  If we can come up with a clear 
description of the behaviors that should be available, then maybe we can 
provide them in mpl.  I would be happy to fix this gap in mpl's handling 
of gappy data, but I can't make it a priority use of my time right now.

For a quick fix, it sounds like what you need is either a function to 
break up your data set into gapless chunks, each of which could be 
plotted by a call to fill, or a function (a variant of poly_between) 
that would replace the gap regions with top and bottom lines at the same 
place (the bottom level? the x-axis?) so the whole thing could be 
plotted in one call to fill, provided the patch outline is suppressed.

I seem to recall someone else with a similar need in the past few 
months, so maybe someone on the list has a ready-made solution for you.

Eric

Chris Withers wrote:
 Eric Firing wrote:
 This is not doing what you think it is,
 
 Indeed, I guess I was seeing nans being treated as missing values rather 
 than being masked...
 
 You should use numpy.masked_where(numpy.isnan(aa), aa).
 
 I am now ;-)
 
 However, I'm still running into problems when I try and plot the gappy 
 data on a filled line as follows:
 
 dates = *an array of datetimes*
 values = *an array containing data values and a few nans*
 values = numpy.ma.masked_where(numpy.isnan(values),values)
 xs,ys = mlab.poly_between(dates,0,values)
 pylab.fill(xs,ys,'r')
 
 For starters, I get this warning:
 
 numpy\core\ma.py:609: UserWarning: Cannot automatically convert masked 
 array to numeric because data is masked in one or more locations.
 
 ...and wherever a NaN occurs in the data, the line is plotted off the 
 top of the axes. I want it to appear at 0 if there's no data. Well, 
 ideally just not appear at all, but I'd settle for appearing at 0...
 
 Any ideas?
 
 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] Why Is This Code Failing?

2008-03-19 Thread Rich Shepard
   Here is the relevant code fragment:

for i in range(1, compList[0][16]):
   pylab.hold(True)
   if compList[0][4] == 'Decay S-Curve':
 testFunctions.zCurve(compList[0][10],compList[0][9])
   elif compList[0][4] == 'Bell Curve':
 testFunctions.gaussCurve(compList[0][14],compList[0][14])
   elif compList[0][4] == 'Growth S-Curve':
 testFunctions.sCurve(compList[0][8],compList[0][11])
   elif compList[0][4] == 'Beta':

testFunctions.betaCurve(compList[0][13],compList[0][12],compList[0][14])
   elif compList[0][4] == 'Data':
 continue
   elif compList[0][4] == 'Linear Increasing':
 testFunctions.linearIncrCurve(compList[0][8],compList[0][11])
   elif compList[0][4] == 'Linear Decreasing':
 testFunctions.linearDecrCurve(compList[0][10],compList[0][9])
   elif compList[0][4] == 'Left Shoulder':

testFunctions.leftShoulderCurve(compList[0][10],compList[0][11],compList[0][9])
   elif compList[0][4] == 'Trapezoid':

testFunctions.trapezoidCurve(compList[0][8],compList[0][10],compList[0][11],compList[0][9])
   elif compList[0][4] == 'Right Shoulder':

testFunctions.rightShoulderCurve(compList[0][8],compList[0][10],compList[0][11])
   elif compList[0][4] == 'Triangle':

testFunctions.triangleCurve(compList[0][8],compList[0][13],compList[0][9])
   elif compList[0][4] == 'Singleton':
 testFunctions.singletonCurve(compList[0][13],compList[0][14])
   elif compList[0][4] == 'Rectangle':

testFunctions.rectangleCurve(compList[0][8],compList[0][10],compList[0][11],compList[0][9])
   elif compList[0][4] == 'Outcome':
 testFunctions.outcomeCurve()
 pylab.savefig(curVar+'.png')
 pylab.hold()

   When it runs in the test script the first curve is plotted in a matplotlib
window and the program pauses until I close that window by clicking on the
upper right button on the frame. Then this traceback is displayed:

Traceback (most recent call last):
   File termset-test-data.py, line 391, in ?
 testCode()
   File termset-test-data.py, line 388, in testCode
 pylab.hold()
   File /usr/lib/python2.4/site-packages/matplotlib/pyplot.py, line 334, in
hold
 rc('axes', hold=b)
   File /usr/lib/python2.4/site-packages/matplotlib/pyplot.py, line 74, in
rc
 matplotlib.rc(*args, **kwargs)
   File /usr/lib/python2.4/site-packages/matplotlib/__init__.py, line 712,
in rc
 rcParams[key] = v
   File /usr/lib/python2.4/site-packages/matplotlib/__init__.py, line 552,
in __setitem__
 cval = self.validate[key](val)
   File /usr/lib/python2.4/site-packages/matplotlib/rcsetup.py, line 43, in
validate_bool
 raise ValueError('Could not convert %s to boolean' % b)
ValueError: Could not convert None to boolean

   What I want is to have all curves from 1 to the maximum number (in
compList[0][16]) plotted on the same set of axes, then save that figure and
go on to the next one.

   Is my problem an indentation error at the end of the IF...ELIF tests?

TIA,

Rich

-- 
Richard B. Shepard, Ph.D.   |  IntegrityCredibility
Applied Ecosystem Services, Inc.|Innovation
http://www.appl-ecosys.com Voice: 503-667-4517  Fax: 503-667-8863

-
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] Efficient scatter() w/ markers from plot()?

2008-03-19 Thread Ted Drain
I need to efficiently plot a set of x,y points where each point has a
different color.  I tried multiple calls to plot() with a single point each
but that is way too slow.  I switched to using scatter() and passing in a
list of colors which works great.  However, I'd really like to have the
marker options from plot() (things like '+' and 'x') which don't work w/
scatter.

What's the easiest way to get the markers from plot() with the efficiency
(and multi-colors) from scatter?

Thanks,
Ted


-
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