当前位置: 首页>>代码示例>>Python>>正文


Python PatchCollection.set_edgecolor方法代码示例

本文整理汇总了Python中matplotlib.collections.PatchCollection.set_edgecolor方法的典型用法代码示例。如果您正苦于以下问题:Python PatchCollection.set_edgecolor方法的具体用法?Python PatchCollection.set_edgecolor怎么用?Python PatchCollection.set_edgecolor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.collections.PatchCollection的用法示例。


在下文中一共展示了PatchCollection.set_edgecolor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: show_uboxes

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
def show_uboxes(uboxes,S=None,col='b',ecol='k', fig=None):
	if uboxes.dim != 2:
		raise Exception("show_uboxes: dimension must be 2")
	if S is None:
		S = range(uboxes.size)

	patches = []
	for i in S:
		art = mpatches.Rectangle(uboxes.corners[i],uboxes.width[0],uboxes.width[1])
		patches.append(art)

	if not fig:
		fig = plt.figure()

	ax = fig.gca()
	ax.hold(True)
	collection = PatchCollection(patches)
	collection.set_facecolor(col)
	collection.set_edgecolor(ecol)
	ax.add_collection(collection,autolim=True)
	ax.autoscale_view()
	plt.draw()
        plt.show()

	return fig
开发者ID:caosuomo,项目名称:rads,代码行数:27,代码来源:gfx.py

示例2: show_uboxes_corners

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
def show_uboxes_corners( corners, width, S=None, col='b', ecol='k' ):
	"""
	This version takes the corners and width arrays as arguments
	instead.
	"""
	if corners.ndim != 2:
		raise Exception("show_uboxes_corners: dimension must be 2")
	if S is None:
		S = range( len(corners) )

	patches = []
	for i in S:
		art = mpatches.Rectangle( corners[i], width[0], width[1] )
		patches.append(art)

	fig = plt.figure()
	ax = fig.gca()
	ax.hold(True)
	collection = PatchCollection(patches)
	collection.set_facecolor(col)
	collection.set_edgecolor(ecol)
	ax.add_collection(collection,autolim=True)
	ax.autoscale_view()
	plt.show()
	
	return fig
开发者ID:caosuomo,项目名称:rads,代码行数:28,代码来源:gfx.py

示例3: plot_depth

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
def plot_depth (mesh_path, fig_name, circumpolar=True):

    # Plotting parameters
    if circumpolar:
        lat_max = -30 + 90
        font_sizes = [240, 192, 160]
    else:
        font_sizes = [30, 24, 20]

    # Build triangular patches for each element
    elements, patches = make_patches(mesh_path, circumpolar)

    # Find the depth of each element
    elm_depth = []
    for elm in elements:
        depth1 = (elm.nodes[0].find_bottom()).depth
        depth2 = (elm.nodes[1].find_bottom()).depth
        depth3 = (elm.nodes[2].find_bottom()).depth
        elm_depth.append(mean(array([depth1, depth2, depth3])))

    # Set up figure
    if circumpolar:
        fig = figure(figsize=(128, 96))
        ax = fig.add_subplot(1,1,1, aspect='equal')
    else:
        fig = figure(figsize=(16, 8))
        ax = fig.add_subplot(1,1,1)    
    # Set colours for patches and add them to plot
    img = PatchCollection(patches, cmap=jet)
    img.set_array(array(elm_depth))
    img.set_edgecolor('face')
    ax.add_collection(img)

    # Configure plot
    if circumpolar:
        xlim([-lat_max, lat_max])
        ylim([-lat_max, lat_max])
        ax.get_xaxis().set_ticks([])
        ax.get_yaxis().set_ticks([])
        axis('off')
    else:
        xlim([-180, 180])
        ylim([-90, 90])
        ax.get_xaxis().set_ticks(arange(-120,120+1,60))
        ax.get_yaxis().set_ticks(arange(-60,60+1,30))
    title('Seafloor depth (m)', fontsize=font_sizes[0])
    cbar = colorbar(img)
    cbar.ax.tick_params(labelsize=font_sizes[2])
    img.set_clim(vmin=0, vmax=max(elm_depth))

    savefig(fig_name)
开发者ID:kaalexander,项目名称:fesomtools,代码行数:53,代码来源:plot_depth.py

示例4: plot_num_layers

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
def plot_num_layers (mesh_path, fig_name):

    # Plotting parameters
    circumpolar = True
    lat_max = -30 + 90
    font_sizes = [240, 192, 160]

    # Build triangular patches for each element
    elements, patches = make_patches(mesh_path, circumpolar)

    # Calculate the number of layers for each element
    num_layers = []
    for elm in elements:
        num_layers_elm = 0
        # Count the number of layers for each node
        for i in range(3):
            node = elm.nodes[i]
            num_layers_node = 1
            # Iterate until we reach the bottom
            while node.below is not None:
                num_layers_node += 1
                node = node.below
            num_layers_elm = max(num_layers_elm, num_layers_node)
        # Save the maximum number of layers across the 3 nodes
        num_layers.append(num_layers_elm)

    # Set up figure
    fig = figure(figsize=(128, 96))
    ax = fig.add_subplot(1,1,1, aspect='equal')
    # Set colours for patches and add them to plot
    img = PatchCollection(patches, cmap=jet)
    img.set_array(array(num_layers))
    img.set_edgecolor('face')
    ax.add_collection(img)

    # Configure plot
    xlim([-lat_max, lat_max])
    ylim([-lat_max, lat_max])
    ax.get_xaxis().set_ticks([])
    ax.get_yaxis().set_ticks([])
    title('Ice shelf draft (m)', fontsize=font_sizes[0])
    cbar = colorbar(img)
    cbar.ax.tick_params(labelsize=font_sizes[2])
    img.set_clim(vmin=1, vmax=47)
    axis('off')

    savefig(fig_name)
开发者ID:kaalexander,项目名称:fesomtools,代码行数:49,代码来源:plot_num_layers.py

示例5: animate

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
        def animate(i):
            [c.remove() for c in ax.collections]

            patches = []
            for (x, y), w in np.ndenumerate(matricies[i]):
                if w != 0.0:
                    patches.append(Rectangle([x - boxsize / 2, y - boxsize / 2],
                                     boxsize, boxsize,
                                     fc=colourmap(w),
                                     ec='black'))

            colors = np.logspace(10e-30, 1, 100, endpoint=True)
            p = PatchCollection(patches)
            p.set_edgecolor('black')
            p.set_array(np.array(colors))
            ax.add_collection(p)
            return ax,
开发者ID:dvp2015,项目名称:pypact,代码行数:19,代码来源:plotadapter.py

示例6: _get_fpt_ell_collection

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
 def _get_fpt_ell_collection(dm, fpts, T_data, alpha, edgecolor):
     ell_patches = []
     for (x, y, a, c, d) in fpts:  # Manually Calculated sqrtm(inv(A))
         with catch_warnings():
             simplefilter("ignore")
             aIS = 1 / sqrt(a)
             cIS = (c / sqrt(a) - c / sqrt(d)) / (a - d + eps(1))
             dIS = 1 / sqrt(d)
         transEll = Affine2D([(aIS, 0, x), (cIS, dIS, y), (0, 0, 1)])
         unitCirc1 = Circle((0, 0), 1, transform=transEll)
         ell_patches = [unitCirc1] + ell_patches
     ellipse_collection = PatchCollection(ell_patches)
     ellipse_collection.set_facecolor("none")
     ellipse_collection.set_transform(T_data)
     ellipse_collection.set_alpha(alpha)
     ellipse_collection.set_edgecolor(edgecolor)
     return ellipse_collection
开发者ID:Erotemic,项目名称:hotspotter,代码行数:19,代码来源:DrawManager.py

示例7: __init__

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
class ArrayDisplay:

    """
    Display a top-town view of a telescope array
    """

    def __init__(self, telx, tely, mirrorarea,
                 axes=None, title="Array", autoupdate=True):

        patches = [Circle(xy=(x, y), radius=np.sqrt(a))
                   for x, y, a in zip(telx, tely, mirrorarea)]

        self.autoupdate = autoupdate
        self.telescopes = PatchCollection(patches)
        self.telescopes.set_clim(0, 100)
        self.telescopes.set_array(np.zeros(len(telx)))
        self.telescopes.set_cmap('spectral_r')
        self.telescopes.set_edgecolor('none')

        self.axes = axes if axes is not None else plt.gca()
        self.axes.add_collection(self.telescopes)
        self.axes.set_aspect(1.0)
        self.axes.set_title(title)
        self.axes.set_xlim(-1000, 1000)
        self.axes.set_ylim(-1000, 1000)

        self.bar = plt.colorbar(self.telescopes)
        self.bar.set_label("Value")

    @property
    def values(self):
        """An array containing a value per telescope"""
        return self.telescopes.get_array()

    @values.setter
    def values(self, values):
        """ set the telescope colors to display  """
        self.telescopes.set_array(values)
        self._update()

    def _update(self):
        """ signal a redraw if necessary """
        if self.autoupdate:
            plt.draw()
开发者ID:jacquemier,项目名称:ctapipe,代码行数:46,代码来源:mpl.py

示例8: draw1DColumn

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
def draw1DColumn(ax, x, val, thk, width=30, ztopo=0, cmin=1, cmax=1000,
                 cmap=None, name=None, textoffset=0.0):
    """Draw a 1D column (e.g., from a 1D inversion) on a given ax.

    Examples
    --------
    >>> import numpy as np
    >>> import matplotlib.pyplot as plt
    >>> from pygimli.mplviewer import draw1DColumn
    >>> thk = [1, 2, 3, 4]
    >>> val = thk
    >>> fig, ax = plt.subplots()
    >>> draw1DColumn(ax, 0.5, val, thk, width=0.1, cmin=1, cmax=4, name="VES")
    <matplotlib.collections.PatchCollection object at ...>
    >>> ax.set_ylim(-np.sum(thk), 0)
    (-10, 0)
    """
    z = -np.hstack((0., np.cumsum(thk), np.sum(thk) * 1.5)) + ztopo
    recs = []
    for i in range(len(val)):
        recs.append(Rectangle((x - width / 2., z[i]), width, z[i + 1] - z[i]))

    pp = PatchCollection(recs)
    col = ax.add_collection(pp)

    pp.set_edgecolor(None)
    pp.set_linewidths(0.0)

    if cmap is not None:
        if isinstance(cmap, str):
            pp.set_cmap(pg.mplviewer.cmapFromName(cmap))
        else:
            pp.set_cmap(cmap)

    pp.set_norm(colors.LogNorm(cmin, cmax))
    pp.set_array(np.array(val))
    pp.set_clim(cmin, cmax)
    if name:
        ax.text(x+textoffset, ztopo, name, ha='center', va='bottom')

    updateAxes_(ax)

    return col
开发者ID:gimli-org,项目名称:gimli,代码行数:45,代码来源:modelview.py

示例9: bwsalt

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
def bwsalt (mesh_path, file_path, save=False, fig_name=None):

    # Plotting parameters
    lat_max = -30 + 90
    circumpolar=True

    # Build FESOM mesh
    elements, patches = make_patches(mesh_path, circumpolar)

    # Calculate annual average of bottom water temperature
    file = Dataset(file_path, 'r')
    data = mean(file.variables['salt'][:,:], axis=0)
    file.close()
    values = []
    # Loop over elements
    for elm in elements:
        values_tmp = []
        # For each component node, find the bottom index; average over
        # all 3 such indices to get the value for this element
        for node in elm.nodes:
            id = node.find_bottom().id
            values_tmp.append(data[id])
        values.append(mean(values_tmp))

    # Plot
    fig = figure(figsize=(16,12))
    ax = fig.add_subplot(1,1,1,aspect='equal')
    img = PatchCollection(patches, cmap=jet)
    img.set_array(array(values))
    img.set_edgecolor('face')
    img.set_clim(vmin=34, vmax=35)
    ax.add_collection(img)
    xlim([-lat_max, lat_max])
    ylim([-lat_max, lat_max])
    axis('off')
    title(r'Bottom water temperature ($^{\circ}$C), annual average', fontsize=30)
    cbar = colorbar(img)
    cbar.ax.tick_params(labelsize=20)

    if save:
        fig.savefig(fig_name)
    else:
        fig.show()
开发者ID:kaalexander,项目名称:fesomtools,代码行数:45,代码来源:bwsalt.py

示例10: plot_shelf

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
def plot_shelf (mesh_path, fig_name):

    # Plotting parameters
    circumpolar = True
    lat_max = -30 + 90
    font_sizes = [240, 192, 160]

    # Build triangular patches for each element
    elements, patches = make_patches(mesh_path, circumpolar)

    # Find the ice shelf draft at each element
    # (i.e. depth of surface nodes in ice shelf cavities)
    elm_shelf = []
    for elm in elements:
        if elm.cavity:
            shelf1 = (elm.nodes[0]).depth
            shelf2 = (elm.nodes[1]).depth
            shelf3 = (elm.nodes[2]).depth
            elm_shelf.append(mean(array([shelf1, shelf2, shelf3])))
        else:
            elm_shelf.append(0.0)

    # Set up figure
    fig = figure(figsize=(128, 96))
    ax = fig.add_subplot(1,1,1, aspect='equal')
    # Set colours for patches and add them to plot
    img = PatchCollection(patches, cmap=jet)
    img.set_array(array(elm_shelf))
    img.set_edgecolor('face')
    ax.add_collection(img)

    # Configure plot
    xlim([-lat_max, lat_max])
    ylim([-lat_max, lat_max])
    ax.get_xaxis().set_ticks([])
    ax.get_yaxis().set_ticks([])
    title('Ice shelf draft (m)', fontsize=font_sizes[0])
    cbar = colorbar(img)
    cbar.ax.tick_params(labelsize=font_sizes[2])
    axis('off')

    savefig(fig_name)
开发者ID:kaalexander,项目名称:fesomtools,代码行数:44,代码来源:plot_shelf.py

示例11: show_box

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
def show_box(b, col="b", ecol="k", alpha=1):
    patches = []

    # lower left corner at b[0], followed by width and height
    xy = b[0]
    width = np.absolute(b[0, 1] - b[0, 0])
    height = np.absolute(b[1, 1] - b[1, 0])
    art = mpatches.Rectangle(xy, width, height)
    # art = mpatches.Rectangle(b[0],b[1,0],b[1,1])
    patches.append(art)

    ax = plt.gca()
    ax.hold(True)
    collection = PatchCollection(patches)
    collection.set_facecolor(col)
    collection.set_edgecolor(ecol)
    collection.set_alpha(alpha)
    ax.add_collection(collection, autolim=True)
    ax.autoscale_view()
    plt.show()
开发者ID:caja-matematica,项目名称:climate_attractors,代码行数:22,代码来源:gfx.py

示例12: plotGeometry

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
 def plotGeometry(self, ax = None):
     if (ax is None):
         fig = plt.figure()
         ax = fig.add_subplot(111)
     ax.set_aspect(1)
     
     self.blockPatch.set_facecolor('#F0F0F0')
     self.blockPatch.set_edgecolor('k')
     ax.add_patch(self.blockPatch)    
     
     pc = PatchCollection(self.channelPatches, match_original = True)
     pc.set_facecolor('w')
     pc.set_edgecolor('k')
     pc.set_zorder(2)
     ax.add_collection(pc)
        
     self.plotDimensions(ax)
     ax.set_xlim(self.xMin, self.xMax)
     ax.set_ylim(self.yMin, self.yMax)
     plt.show()
开发者ID:SysMo,项目名称:SmoWeb,代码行数:22,代码来源:HeatExchangerProfilePlots.py

示例13: show_boxes

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
def show_boxes(boxes, S=None, col="b", ecol="k", alpha=1):
    if boxes.dim != 2:
        raise Exception("show_boxes: dimension must be 2")
    if S is None:
        S = range(boxes.size)

    patches = []
    for i in S:
        art = mpatches.Rectangle(boxes.corners[i], boxes.widths[i][0], boxes.widths[i][1])
        patches.append(art)

    ax = plt.gca()
    ax.hold(True)
    collection = PatchCollection(patches)
    collection.set_facecolor(col)
    collection.set_edgecolor(ecol)
    collection.set_alpha(alpha)
    ax.add_collection(collection, autolim=True)
    ax.autoscale_view()
    plt.show()
开发者ID:caja-matematica,项目名称:climate_attractors,代码行数:22,代码来源:gfx.py

示例14: make_plot

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
  def make_plot(self, val, cct, clm,
                cmap = 'jet', cmap_norm = None,
                cmap_vmin = None, cmap_vmax = None):

    # make color mapping
    smap = ScalarMappable(cmap_norm, cmap)
    smap.set_clim(cmap_vmin, cmap_vmax)
    smap.set_array(val)
    bin_colors = smap.to_rgba(val)

    # make patches
    patches = []
    for i_c, i_clm in enumerate(clm):
      patches.append(Rectangle((i_clm[0],  i_clm[2]),
                                i_clm[1] - i_clm[0],
                                i_clm[3] - i_clm[2]))
    patches_colle = PatchCollection(patches)
    patches_colle.set_edgecolor('face')
    patches_colle.set_facecolor(bin_colors)

    return patches_colle, smap
开发者ID:shiaki,项目名称:astro-viskit,代码行数:23,代码来源:adapt_hist.py

示例15: plot_cavityflag

# 需要导入模块: from matplotlib.collections import PatchCollection [as 别名]
# 或者: from matplotlib.collections.PatchCollection import set_edgecolor [as 别名]
def plot_cavityflag (mesh_path, fig_name):

    # Plotting parameters
    circumpolar = True
    lat_max = -30 + 90
    font_sizes = [240, 192, 160]

    # Build triangular patches for each element
    elements, patches = make_patches(mesh_path, circumpolar)

    # For each element, get the cavity flag
    cavity = []
    for elm in elements:
        if elm.cavity:
            cavity.append(1)
        else:
            cavity.append(0)

    # Set up figure
    fig = figure(figsize=(128, 96))
    ax = fig.add_subplot(1,1,1, aspect='equal')
    # Set colours for patches and add them to plot
    img = PatchCollection(patches, cmap=jet)
    img.set_array(array(cavity))
    img.set_edgecolor('face')
    ax.add_collection(img)

    # Configure plot
    xlim([-lat_max, lat_max])
    ylim([-lat_max, lat_max])
    ax.get_xaxis().set_ticks([])
    ax.get_yaxis().set_ticks([])
    title('Ice shelf cavity flag', fontsize=font_sizes[0])
    cbar = colorbar(img)
    cbar.ax.tick_params(labelsize=font_sizes[2])
    img.set_clim(vmin=0, vmax=1)
    axis('off')

    savefig(fig_name)
开发者ID:kaalexander,项目名称:fesomtools,代码行数:41,代码来源:plot_cavityflag.py


注:本文中的matplotlib.collections.PatchCollection.set_edgecolor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。