chicken/egg (or figure/canvas) question

I thought I had this understood, but now I am confused while working on my last chapter. I know that the Figure object never directly creates its own canvas object. It starts off with a None object as a placeholder and waits for one to be given to it. However, I can only find one place where the figure object’s set_canvas() method is called, and that is in the canvas’s print_figure() method to restore itself as the figure’s canvas after temporaraily switching to another backend for saving.

I thought that the FigureManager initializes the primary canvas object, but that doesn’t seem to be the case. Where is it done?

Cheers!

Ben Root

Actually, I think I found it. It looks like each backend defines a new_figure_manager() function. Then, in backends/init.py, not only do the aliased FigureManager and FigureCanvas objects get imported from the appropriate module, but so does that function. It is pylab_setup() in the backends/init.py that creates the canvas object, it seems?

I guess this is one of those remaining issues that is keeping us from fully separating pyplot from the rest of matplotlib?

Cheers!

Ben Root

···

On Sat, Nov 22, 2014 at 4:30 PM, Benjamin Root <ben.root@…553…> wrote:

I thought I had this understood, but now I am confused while working on my last chapter. I know that the Figure object never directly creates its own canvas object. It starts off with a None object as a placeholder and waits for one to be given to it. However, I can only find one place where the figure object’s set_canvas() method is called, and that is in the canvas’s print_figure() method to restore itself as the figure’s canvas after temporaraily switching to another backend for saving.

I thought that the FigureManager initializes the primary canvas object, but that doesn’t seem to be the case. Where is it done?

Cheers!

Ben Root