Python matplotlib.transforms.Bbox.from_extents() Examples
The following are 8
code examples of matplotlib.transforms.Bbox.from_extents().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.transforms.Bbox
, or try the search function
.
Example #1
Source File: MicapsData.py From PyMICAPS with GNU General Public License v2.0 | 6 votes |
def UpdateExtents(self, products): """ 更新产品参数的extents :param products: 产品参数对象 :return: """ if products.picture.extents is None: maxlon = max(self.endlon, self.beginlon) minlon = min(self.endlon, self.beginlon) maxlat = max(self.endlat, self.beginlat) minlat = min(self.endlat, self.beginlat) margin = products.picture.margin xmax = maxlon + margin[2] if maxlon + margin[2] <= 180 else 180 xmin = minlon - margin[0] if minlon - margin[0] >= -180 else -180 ymax = maxlat + margin[1] if maxlat + margin[1] <= 90 else 90 ymin = minlat - margin[3] if minlat - margin[3] >= -90 else -90 products.picture.extents = Bbox.from_extents(xmin, ymin, xmax, ymax) else: extents = products.picture.extents if isinstance(extents, list): products.picture.extents = Bbox.from_extents(extents[0], extents[1], extents[2], extents[3])
Example #2
Source File: gridspec.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def get_position(self, figure, return_all=False): """Update the subplot position from ``figure.subplotpars``. """ gridspec = self.get_gridspec() nrows, ncols = gridspec.get_geometry() rows, cols = np.unravel_index( [self.num1] if self.num2 is None else [self.num1, self.num2], (nrows, ncols)) fig_bottoms, fig_tops, fig_lefts, fig_rights = \ gridspec.get_grid_positions(figure) fig_bottom = fig_bottoms[rows].min() fig_top = fig_tops[rows].max() fig_left = fig_lefts[cols].min() fig_right = fig_rights[cols].max() figbox = Bbox.from_extents(fig_left, fig_bottom, fig_right, fig_top) if return_all: return figbox, rows[0], cols[0], nrows, ncols else: return figbox
Example #3
Source File: gridspec.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def get_position(self, figure, return_all=False): """Update the subplot position from ``figure.subplotpars``. """ gridspec = self.get_gridspec() nrows, ncols = gridspec.get_geometry() rows, cols = np.unravel_index( [self.num1] if self.num2 is None else [self.num1, self.num2], (nrows, ncols)) fig_bottoms, fig_tops, fig_lefts, fig_rights = \ gridspec.get_grid_positions(figure) fig_bottom = fig_bottoms[rows].min() fig_top = fig_tops[rows].max() fig_left = fig_lefts[cols].min() fig_right = fig_rights[cols].max() figbox = Bbox.from_extents(fig_left, fig_bottom, fig_right, fig_top) if return_all: return figbox, rows[0], cols[0], nrows, ncols else: return figbox
Example #4
Source File: gridspec.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def get_position(self, figure, return_all=False): """Update the subplot position from ``figure.subplotpars``. """ gridspec = self.get_gridspec() nrows, ncols = gridspec.get_geometry() rows, cols = np.unravel_index( [self.num1] if self.num2 is None else [self.num1, self.num2], (nrows, ncols)) fig_bottoms, fig_tops, fig_lefts, fig_rights = \ gridspec.get_grid_positions(figure) fig_bottom = fig_bottoms[rows].min() fig_top = fig_tops[rows].max() fig_left = fig_lefts[cols].min() fig_right = fig_rights[cols].max() figbox = Bbox.from_extents(fig_left, fig_bottom, fig_right, fig_top) if return_all: return figbox, rows[0], cols[0], nrows, ncols else: return figbox
Example #5
Source File: gridspec.py From coffeegrindsize with MIT License | 6 votes |
def get_position(self, figure, return_all=False): """Update the subplot position from ``figure.subplotpars``. """ gridspec = self.get_gridspec() nrows, ncols = gridspec.get_geometry() rows, cols = np.unravel_index( [self.num1] if self.num2 is None else [self.num1, self.num2], (nrows, ncols)) fig_bottoms, fig_tops, fig_lefts, fig_rights = \ gridspec.get_grid_positions(figure) fig_bottom = fig_bottoms[rows].min() fig_top = fig_tops[rows].max() fig_left = fig_lefts[cols].min() fig_right = fig_rights[cols].max() figbox = Bbox.from_extents(fig_left, fig_bottom, fig_right, fig_top) if return_all: return figbox, rows[0], cols[0], nrows, ncols else: return figbox
Example #6
Source File: gridspec.py From CogAlg with MIT License | 6 votes |
def get_position(self, figure, return_all=False): """ Update the subplot position from ``figure.subplotpars``. """ gridspec = self.get_gridspec() nrows, ncols = gridspec.get_geometry() rows, cols = np.unravel_index( [self.num1] if self.num2 is None else [self.num1, self.num2], (nrows, ncols)) fig_bottoms, fig_tops, fig_lefts, fig_rights = \ gridspec.get_grid_positions(figure) fig_bottom = fig_bottoms[rows].min() fig_top = fig_tops[rows].max() fig_left = fig_lefts[cols].min() fig_right = fig_rights[cols].max() figbox = Bbox.from_extents(fig_left, fig_bottom, fig_right, fig_top) if return_all: return figbox, rows[0], cols[0], nrows, ncols else: return figbox
Example #7
Source File: gridspec.py From twitter-stock-recommendation with MIT License | 6 votes |
def get_position(self, figure, return_all=False): """Update the subplot position from ``figure.subplotpars``. """ gridspec = self.get_gridspec() nrows, ncols = gridspec.get_geometry() rows, cols = np.unravel_index( [self.num1] if self.num2 is None else [self.num1, self.num2], (nrows, ncols)) fig_bottoms, fig_tops, fig_lefts, fig_rights = \ gridspec.get_grid_positions(figure) fig_bottom = fig_bottoms[rows].min() fig_top = fig_tops[rows].max() fig_left = fig_lefts[cols].min() fig_right = fig_rights[cols].max() figbox = Bbox.from_extents(fig_left, fig_bottom, fig_right, fig_top) if return_all: return figbox, rows[0], cols[0], nrows, ncols else: return figbox
Example #8
Source File: Picture.py From PyMICAPS with GNU General Public License v2.0 | 4 votes |
def __init__(self, root, clipborders): p = root.find("Picture") # 生成的图片宽度 self.width = Projection.leaf_to_float(p, "PicWidth", 10) # 生成的图片高度 self.height = Projection.leaf_to_float(p, "PicHeight", 10) # dpi self.dpi = Projection.leaf_to_int(p, "Dpi", 72) # 高宽比 self.widthshrink = Projection.leaf_to_float(p, "WidthShrink", 1.0) # 绘图区外延 self.margin = Projection.leaf_to_list(p, "Margin", [0, 0, 0, 0]) # 绘图区内边距 self.pad = Projection.leaf_to_float(p, "Pad", 0.0) # 绘图区域 extents = p.find("Extents").text.strip() if extents is None or extents == '': if len(clipborders) < 1 or clipborders[0].path is None or (not clipborders[0].using): self.extents = None else: jxextend = clipborders[0].path.get_extents() delta = self.margin xmax = jxextend.xmax + delta[2] xmin = jxextend.xmin - delta[0] ymax = jxextend.ymax + delta[1] ymin = jxextend.ymin - delta[3] self.extents = Bbox.from_extents(xmin, ymin, xmax, ymax) else: self.extents = Projection.leaf_to_list(p, "Extents", None) # 画布透明度 self.opacity = Projection.leaf_to_float(p, 'Opacity', 1) if self.opacity < 0 or self.opacity > 1: self.opacity = 1 # 生成的图片文件存放路径 self.picfile = Projection.leaf_to_string(p, 'PicFile', 'mytest.png') self.checkFilename() return