Hello Stefanie,

I think the problem is that you try to initialise a subplot with
subplot(112)
which is not possible, because the first to numbers in 112 define the subplot 
structure / geometry (here 1 by 1) and the last number give the index of the 
subplot.
In general you could use N x M (N rows and M columns) for subplots by
subplot(N,M,index)
where 'index' would be a number between 1 and N * M.

best regards Matthias 

On Wednesday 13 May 2009 14:02:57 Stefanie Lück wrote:
> Hello!
>
> I'm trying to draw several plots on after the other in a wxScrolledPanel
> but I got the error message:
>
> Traceback (most recent call last):
>   File "D:\Eigene Datein\Python\current\RNAiscan\Test\sample.py", line 96,
> in <m odule>
>     frame = MyFrame()
>   File "D:\Eigene Datein\Python\current\RNAiscan\Test\sample.py", line 56,
> in __ init__
>     self.plot_data(self.fig)
>   File "D:\Eigene Datein\Python\current\RNAiscan\Test\sample.py", line 90,
> in pl ot_data
>     a = figure.add_subplot(id)
>   File "C:\python25\lib\site-packages\matplotlib\figure.py", line 689, in
> add_su bplot
>     a = subplot_class_factory(projection_class)(self, *args, **kwargs)
>   File "C:\python25\lib\site-packages\matplotlib\axes.py", line 7207, in
> __init_ _
>     raise ValueError( 'Subplot number exceeds total subplots')
> ValueError: Subplot number exceeds total subplots
>
> Here's my code:
>
> # -*- coding: latin1 -*-
> import sys
>
> import wx
> import wx.lib.scrolledpanel as SP
> from wx.lib.mixins.listctrl import CheckListCtrlMixin
>
> from matplotlib.backends.backend_wx import FigureCanvasWx
> from matplotlib.figure import Figure
> import matplotlib.numerix as numpy
>
> from pylab import array, arange, sin, cos, exp, pi, randn, normpdf,
> meshgrid, \ convolve
>
> d = {1: (' Contig5535', '230 '), 2: (' Contig5534', '3240 '), 3: (' test',
> '574')}
>
> class CheckListCtrl(wx.ListCtrl, CheckListCtrlMixin):
>     def __init__(self, parent):
>         wx.ListCtrl.__init__(self, parent, -1,
> style=wx.LC_REPORT|wx.LC_VRULES|wx.LC_HRULES|wx.LC_SORT_ASCENDING)
> CheckListCtrlMixin.__init__(self)
>         self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)
>
>     def OnItemActivated(self, evt):
>         self.ToggleItem(evt.m_itemIndex)
>
>     def OnCheckItem(self, index, flag):
>         data = self.GetItemData(index)
>         title = d[data][1]
>         if flag:
>             what = "checked"
>         else:
>             what = "unchecked"
>
> class MyFrame(wx.Frame):
>
>     def __init__(self):
>         wx.Frame.__init__(self, None, -1, "My Frame", size=(300, 300))
>         self.panel = SP.ScrolledPanel(self, -1)
>
>         self.list = CheckListCtrl(self.panel)
>         self.list.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.NORMAL))
>
>         vbox = wx.BoxSizer(wx.VERTICAL)
>
>         self.fig = Figure()
>         self.canvas = FigureCanvasWx(self.panel, -1, self.fig)
>         self.plot_data(self.fig)
>         vbox.Add(self.list,0, wx.EXPAND)
>         vbox.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.GROW)
>
>         self.panel.SetSizer(vbox)
>         self.panel.SetAutoLayout(1)
>         self.panel.SetupScrolling()
>
>         self.list.InsertColumn(0, "ID")
>         self.list.InsertColumn(1, "Nr. of Hits")
>         for key, data in d.iteritems():
>             index = self.list.InsertStringItem(sys.maxint, data[0])
>             self.list.SetStringItem(index, 1, data[1])
>             #self.list.SetStringItem(index, 2, data[2])
>             self.list.SetItemData(index, key)
>         self.list.SetColumnWidth(0, wx.LIST_AUTOSIZE)
>         self.list.SetColumnWidth(1, 100)
>         self.Show()
>
>     def plot_data(self, figure):
>         liste2 = ['Contig5535_range.txtcounts.txt',
> 'Contig5534_range.txtcounts.txt'] id = 111
>
>         for q in liste2:
>             f = open(q, 'r')
>             data = f.readlines()
>             liste3 = []
>             liste4 = []
>             for line in data:
>                 line = line.strip()
>                 x = line.split(" ")
>                 liste3.append(int(x[0]))
>                 liste4.append(int(x[1]))
>
>             a = figure.add_subplot(id)
>             a.plot(liste3,liste4)
>             id = id + 1
>
> if __name__ == '__main__':
>     app = wx.PySimpleApp()
>     frame = MyFrame()
>     frame.Show(True)
>     app.MainLoop()
>
> Has someone an idea how to solve this?
> Thank in advance
> Stefanie



------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to