[Matplotlib-users] [Mac OS 10.4.7, Python 2.4.3] Problem using plot_date

2006-08-23 Thread David Goldsmith
First, sorry for the long email.

I'm having a segmentation fault problem trying to use plot_date, 
somewhere deep in matplotlib.  After giving up trying to figure out what 
was going wrong from within my real code, I wrote a minimal sample 
to try to reproduce (or not) the problem; here it is:

import datetime as dt
import wx
import matplotlib as mpl
import wxmpl

class PlotPanel(wxmpl.PlotPanel):
def __init__(self, parent, *args, **kwargs):
wxmpl.PlotPanel.__init__(self, parent, wx.ID_ANY, *args, **kwargs)
self.set_crosshairs(False)
self.Figure = self.get_figure()
ax = self.Figure.add_subplot(111)
ax.clear()
ax.grid(False)
zerodate = dt.datetime(2001,2,15)
zero = mpl.dates.date2num(zerodate)
x = range(int(zero), int(zero)+11)
ax.plot_date(x,x) # Problem line; works fine with plot instead 
of plot_date
self.draw()

class MainFrame(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.PlotPanel = PlotPanel(self)
self.MainBox = wx.BoxSizer(wx.VERTICAL)
self.MainBox.Add(self.PlotPanel, 1,  wx.EXPAND )
self.SetSizerAndFit(self.MainBox)

class App(wx.App):
def OnInit(self):
self.frame = MainFrame(None)
self.SetTopWindow(self.frame)
self.frame.Fit()
self.frame.Show()
return True

if __name__ == __main__:
print wx.__version__
print wxmpl.__version__
print mpl.__version__
app = App(0)
app.MainLoop()

This code runs fine with plot instead of plot_date (just like my 
original code with the same substitution).  But with plot_date, I get 
(please note the versions I'm using):

wx.__version__ =  2.6.3.3
wxmpl.__version__ =  1.2.7
matplotlib.__version__ =  0.87.4
Traceback (most recent call last):
  File debugplot_date.py, line 40, in ?
app = App(0)
  File 
//Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/wx-2.6-mac-unicode/wx/_core.py,
 
line 7700, in __init__
self._BootstrapApp()
  File 
//Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/wx-2.6-mac-unicode/wx/_core.py,
 
line 7352, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
  File debugplot_date.py, line 30, in OnInit
self.frame = MainFrame(None)
  File debugplot_date.py, line 23, in __init__
self.PlotPanel = PlotPanel(self)
  File debugplot_date.py, line 18, in __init__
self.draw()
  File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/wxmpl.py,
 
line 1189, in draw
else:
  File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/backends/backend_wxagg.py,
 
line 61, in draw
FigureCanvasAgg.draw(self)
  File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/backends/backend_agg.py,
 
line 391, in draw
self.figure.draw(renderer)
  File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/figure.py,
 
line 532, in draw
for a in self.axes: a.draw(renderer)
  File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/axes.py,
 
line 1045, in draw
a.draw(renderer)
  File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/axis.py,
 
line 548, in draw
majorLabels = [self.major.formatter(val, i) for i, val in 
enumerate(majorLocs)]
  File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/dates.py,
 
line 369, in __call__
return self._formatter(x, pos)
  File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/dates.py,
 
line 247, in __call__
dt = num2date(x, self.tz)
  File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/dates.py,
 
line 205, in num2date
if not iterable(x): return _from_ordinalf(x, tz)
  File 
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/dates.py,
 
line 156, in _from_ordinalf
hour, remainder = divmod(24*remainder, 1)
ValueError: need more than 0 values to unpack

Using winpdb, I determined that this line in dates.py get called 13 
times before, on the 14th time, it causes a communication failure 
between winpdb and the code.

Any ideas what's up?  Thanks in advance,

DG

PS: I'm on a Mac, running system 10.4.7 with Python 2.4.3 (#1, Apr  7 
2006, 10:54:33) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642

Re: [Matplotlib-users] Getting started with bar charts

2006-08-23 Thread Jouni K Seppänen
[Again copying to matplotlib-users; maybe the main developers can  
comment on whether these shortcomings in the getp/setp interface  
should be fixed.]

Hi Derek,

 It does seem as those these settings affect the top and bottom of  
 the graph - I was wondering if it was possible to show tickmarks  
 along the bottom edge but not the top edge?

I don't think that's directly supported. Here's a hacky way to do it:

 lines = getp(gca(), 'xticklines')
 toplines = [ l for l in lines if getp(l, 'ydata') == (1,) ]
 setp(toplines, visible=False)

How I came up with this: I knew that I wanted to make some of the  
xticklines invisible, so I looked at the list of line objects for  
clues as to what differs between them. They seem to have xdata and  
ydata properties, and ydata is (0,) for half of the lines and (1,)  
for the other half, so it looks like it is the vertical position in  
axis coordinates. (xdata seems to be in data coordinates.)

 And the other property I do not see on the list is the one that  
 shows whether a tick goes into the graph or just out - in the  
 prc file, there is a line:
  xtick.direction  : in # direction: in or out
 but there is no direction' property?

You're right, there is no obvious property to control this. Here's an  
even hackier way to do this (and one that doesn't look very future- 
proof):

 for l in getp(gca(), 'xticklines'):
 setp(l, 'marker', 5-getp(l, 'marker'))

The line objects have a marker property, which is 2 for some markers  
and 3 for the others... so I guessed that one of them means upwards  
and the other downwards, and checked this guess by flipping the  
xtick.direction parameter and looking again. So subtracting the  
marker from 5 flips the direction.

I wonder how this is done in Matlab?

 label: any string

 which shows me that the Yaxis has a label - in this case a
 string - but I do not see how one can set the font properties
 for the Yaxis label as it is not Text object??

I think you cannot do this with setp alone. Use the ylabel command:

 ylabel('foo bar', fontsize=18)

-- 
Jouni



-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Getting started with bar charts

2006-08-23 Thread Darren Dale
On Wednesday 23 August 2006 2:52 am, Jouni K Seppänen wrote:
 [Again copying to matplotlib-users; maybe the main developers can
 comment on whether these shortcomings in the getp/setp interface
 should be fixed.]

 Hi Derek,

  It does seem as those these settings affect the top and bottom of
  the graph - I was wondering if it was possible to show tickmarks
  along the bottom edge but not the top edge?

from pylab import *

a=axes()
a.xaxis.tick_bottom()
show()

-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] py2exe matplotlib problem

2006-08-23 Thread Jenny choe
Hi,I'm trying to make an executable using python 2.4.3 py2exe 0.6.8 Matplot 0.87.4I've tried the setup file described in 
http://starship.python.net/crew/theller/moin.cgi/MatPlotLib
 but it didn't work. The error message that I've got was this below.Is there anybody who know how to make a setup file with matplotlib.get_py2exe_datafiles() ?Thanks,Jenny

C:\DDTAF\RunDDTAF.exe sTraceback (most recent call last): File main.py, line 3, in ?ImportError: No module named pylabC:\DDTAF\RunpausePress any key to continue . . .


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=121642___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users