0

I have one class:

class CalcPlot(HasTraits):
    display = Instance(Figure)
    ax1 = self.display.axes[0]
    x = np.linspace(0,10,11)
    y = np.linspace(0,10,11)
    self.display = ax1.plot(x,y,color='r',marker='o')
    wx.CallAfter(self.display.canvas.draw)

    def _display_default(self):
        figure = Figure()
        ax1 = figure.add_subplot(111)
        ax1 = figure.axes[0]

Obviously the above code doesn't work. How would I access the display instance in a different class if I wanted to draw a new figure.

Griff
  • 2,064
  • 5
  • 31
  • 47
  • 1
    You should not be thinking about drawing onto a canvas, you should be thinking about plotting onto an axes object. I assume you are embedding this is something? See the proper example [here](http://matplotlib.org/examples/user_interfaces/). You should only be thinking about the canvas to do the embedding. – tacaswell Feb 20 '13 at 02:46
  • Yes sorry that is what I meant. Though, those tutorials don't make use of traits. Any suggestions? – Griff Feb 20 '13 at 03:31
  • See this link http://www.scipy.org/Cookbook/EmbeddingInTraitsGUI . I have never used traits, so I can't be of much more help, sorry. – tacaswell Feb 20 '13 at 03:45
  • Thanks. That is nearly there, though the plot is being made in a method outside the class, not in another entire class of its own. I'll see what the Traits mail group has to say... thanks. – Griff Feb 20 '13 at 04:25

0 Answers0