Thanks a lot! Problem solved!


----- Original Message ----- From: "Matthias Michler" <MatthiasMichler@...361...>
To: <>
Sent: Wednesday, May 13, 2009 2:16 PM
Subject: Re: [Matplotlib-users] Subplots

Hello Stefanie,

I think the problem is that you try to initialise a subplot with
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
In general you could use N x M (N rows and M columns) for subplots by
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:


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\", line 96,
in <m odule>
    frame = MyFrame()
  File "D:\Eigene Datein\Python\current\RNAiscan\Test\", line 56,
in __ init__
  File "D:\Eigene Datein\Python\current\RNAiscan\Test\", line 90,
in pl ot_data
    a = figure.add_subplot(id)
  File "C:\python25\lib\site-packages\matplotlib\", line 689, in
add_su bplot
    a = subplot_class_factory(projection_class)(self, *args, **kwargs)
  File "C:\python25\lib\site-packages\matplotlib\", 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',

class CheckListCtrl(wx.ListCtrl, CheckListCtrlMixin):
    def __init__(self, parent):
        wx.ListCtrl.__init__(self, parent, -1,
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated)

    def OnItemActivated(self, evt):

    def OnCheckItem(self, index, flag):
        data = self.GetItemData(index)
        title = d[data][1]
        if flag:
            what = "checked"
            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)
        vbox.Add(self.list,0, wx.EXPAND)
        vbox.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.GROW)


        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)

    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(" ")

            a = figure.add_subplot(id)
            id = id + 1

if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = MyFrame()

Has someone an idea how to solve this?
Thank in advance

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.
Matplotlib-users mailing list