MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / FigureCanvasTemplate

Class FigureCanvasTemplate

lib/matplotlib/backends/backend_template.py:149–203  ·  view source on GitHub ↗

The canvas the figure renders into. Calls the draw and print fig methods, creates the renderers, etc. Note: GUI templates will want to connect events for button presses, mouse movements and key presses to functions that call the base class methods button_press_event, button_re

Source from the content-addressed store, hash-verified

147
148
149class FigureCanvasTemplate(FigureCanvasBase):
150 """
151 The canvas the figure renders into. Calls the draw and print fig
152 methods, creates the renderers, etc.
153
154 Note: GUI templates will want to connect events for button presses,
155 mouse movements and key presses to functions that call the base
156 class methods button_press_event, button_release_event,
157 motion_notify_event, key_press_event, and key_release_event. See the
158 implementations of the interactive backends for examples.
159
160 Attributes
161 ----------
162 figure : `~matplotlib.figure.Figure`
163 A high-level Figure instance
164 """
165
166 # The instantiated manager class. For further customization,
167 # ``FigureManager.create_with_canvas`` can also be overridden; see the
168 # wx-based backends for an example.
169 manager_class = FigureManagerTemplate
170
171 def draw(self):
172 """
173 Draw the figure using the renderer.
174
175 It is important that this method actually walk the artist tree
176 even if not output is produced because this will trigger
177 deferred work (like computing limits auto-limits and tick
178 values) that users may want access to before saving to disk.
179 """
180 renderer = RendererTemplate(self.figure.dpi)
181 self.figure.draw(renderer)
182
183 # You should provide a print_xxx function for every file format
184 # you can write.
185
186 # If the file type is not in the base set of filetypes,
187 # you should add it to the class-scope filetypes dictionary as follows:
188 filetypes = {**FigureCanvasBase.filetypes, 'foo': 'My magic Foo format'}
189
190 def print_foo(self, filename, **kwargs):
191 """
192 Write out format foo.
193
194 This method is normally called via `.Figure.savefig` and
195 `.FigureCanvasBase.print_figure`, which take care of setting the figure
196 facecolor, edgecolor, and dpi to the desired output values, and will
197 restore them to the original values. Therefore, `print_foo` does not
198 need to handle these settings.
199 """
200 self.draw()
201
202 def get_default_filetype(self):
203 return 'foo'
204
205
206########################################################################

Callers 1

test_load_old_apiFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_load_old_apiFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…