def add_subplot(self, *args, **kwargs): """ Add an a subplot, eg add_subplot(111) or add_subplot(212, axisbg='r') The Axes instance will be returned """ ispolar = kwargs.get('polar', False) dict_delall(kwargs, ('polar', )) if ispolar: a = PolarSubplot(self, *args, **kwargs) else: a = Subplot(self, *args, **kwargs) self.axes.append(a) return a
def add_subplot(self, *args, **kwargs): """ Add a subplot. Examples add_subplot(111) add_subplot(1,1,1) # equivalent but more general add_subplot(212, axisbg='r') # add subplot with red background add_subplot(111, polar=True) # add a polar subplot add_subplot(sub) # add Subplot instance sub kwargs are legal Axes kwargs plus"polar" which sets whether to create a polar axes. The Axes instance will be returned. If the figure already has a subplot with key *args, *kwargs then it will simply make that subplot current and return it The following kwargs are supported: %(Axes)s """ key = self._make_key(*args, **kwargs) if self._seen.has_key(key): ax = self._seen[key] self.sca(ax) return ax if not len(args): return if isinstance(args[0], Subplot) or isinstance(args[0], PolarSubplot): a = args[0] assert (a.get_figure() is self) else: ispolar = kwargs.pop('polar', False) if ispolar: a = PolarSubplot(self, *args, **kwargs) else: a = Subplot(self, *args, **kwargs) self.axes.append(a) self._axstack.push(a) self.sca(a) self._seen[key] = a return a
def add_subplot(self, *args, **kwargs): """ Add an a subplot. Examples add_subplot(111) add_subplot(212, axisbg='r') # add subplot with red background add_subplot(111, polar=True) # add a polar subplot add_subplot(sub) # add Subplot instance sub kwargs are legal Axes kwargs plus"polar" which sets whether to create a polar axes. The Axes instance will be returned. If the figure already has a subplot with key *args, *kwargs then it will simply make that subplot current and return it """ key = args, tuple(kwargs.items()) if self._seen.has_key(key): ax = self._seen[key] self.sca(ax) return ax if not len(args): return if isinstance(args[0], Subplot) or isinstance(args, PolarSubplot): a = args[0] a.set_figure(self) else: ispolar = popd(kwargs, 'polar', False) if ispolar: a = PolarSubplot(self, *args, **kwargs) else: a = Subplot(self, *args, **kwargs) self.axes.append(a) self._axstack.push(a) self.sca(a) self._seen[key] = a return a