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


Python Rectangle.set_edgecolor方法代码示例

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


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

示例1: _make_plot

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_edgecolor [as 别名]
 def _make_plot(self):
     """ """
     self.axis.clear()
     scaler = self._make_scaler()
     
     logger.debug("{} fields on this coverage plot".format(len(self.fields)))
     
     sorted_field_indices = np.argsort([f.number_of_exposures for f in self.fields])
     for idx in sorted_field_indices:
         # Sort the fields by number of observations, so the fields with more observations appear on top
         field = self.fields[idx]
         kwargs = self._field_kwargs[idx]
         
         # Compute the size of the field in the horizontal and vertical directions
         try:
             xsize = camera_size_degrees[0] / np.cos(field.dec.radians)
             ysize = camera_size_degrees[1]
         except AttributeError:
             # The field has no 'dec'
             continue
         
         # Compute the coordinates of the top left corner of the rectangle
         rec_x1 = ((field.ra.degrees + (camera_size_degrees[0] / np.cos(field.dec.radians)) / 2.) % 360.) * -1 + 180 # degrees
         rec_y1 = field.dec.degrees - camera_size_degrees[1] / 2. # degrees
         
         if kwargs.has_key("alpha"):
             alpha = kwargs["alpha"]
             del kwargs["alpha"]
         else:
             alpha = None
         
         if kwargs.has_key("color"):
             color = kwargs["color"]
             del kwargs["color"]
         else:
             # TODO: use scaler to get the color of this field
             if self.color_map == None:
                 color = (0.,0.,0.,)
                 if alpha == None:
                     alpha = scaler(field.number_of_exposures)*0.5 + 0.1
             else:
                 self.color_map(scaler(field.number_of_exposures))
         
         if alpha == None:
             alpha = 0.2
         
         rec = Rectangle((np.radians(rec_x1), np.radians(rec_y1)), \
                         -np.radians(xsize), np.radians(ysize), \
                         color=color, alpha=alpha, **kwargs)
             
         rec.set_edgecolor("none")
         self.axis.add_patch(rec)
     
     if self.projection in ["aitoff", "hammer", "mollweide"]:
         self.axis.set_xticklabels([330, 300, 270, 240, 210, 180, 150, 120, 90, 60, 30])
     
     if self.projection == "rectilinear":
         self.axis.set_xlim(-3.14159, 3.14159)
         self.axis.set_ylim(-3.14159/2., 3.14159/2)
     
     self.axis.legend(bbox_to_anchor=(0.8, 0.17), ncol=3, fancybox=True, shadow=True)
开发者ID:adrn,项目名称:PTF,代码行数:63,代码来源:survey_coverage.py

示例2: FontProperties

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_edgecolor [as 别名]
import matplotlib.pyplot as plt
import numpy as np
import numpy.random as npr
import utilities_nopd as utils
from matplotlib.font_manager import FontProperties
from matplotlib.patches import Rectangle
import colorbrewer as cb
from mpltools import color

legend_font = FontProperties()
legend_font.set_size('small')
ticks_font = FontProperties(family='Helvetica', style='normal', \
                            size=8, weight='normal', stretch='normal')
empty_rect = Rectangle((0,0),1,1)
empty_rect.set_alpha(0)
empty_rect.set_edgecolor('white')
color_scheme_names = ['BrBG', 'PiYG', 'PRGn', 'RdBu', 'RdGy', 'PuOr', \
    'RdYlBu', 'RdYlGn', 'Spectral']
color_schemes = {}
for name in color_scheme_names:
    color_schemes[name] = eval('cb.{0}'.format(name))

def to_rgb(t):
    """
    Args:
        t: 3-tuple of int's in range [0,255]
    
    Returns:
        out: 3-tuple of float's in range [0,1]
    """
    r,g,b = np.array(t)/255.
开发者ID:mattflor,项目名称:wspec,代码行数:33,代码来源:visualization_nopd.py

示例3: draw_chiprep2

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_edgecolor [as 别名]

#.........这里部分代码省略.........
        ell_alpha
        ell_bit 
        xy_bit
        ell_color
        """
        # Allows display of cross database queries
        cm = dm.hs.cm if qcm is None else qcm
        # Grab Preferences
        xy_bit = dm.draw_prefs.points_bit if xy_bit is None else xy_bit
        ell_bit = dm.draw_prefs.ellipse_bit if ell_bit is None else ell_bit
        bbox_bit = dm.draw_prefs.bbox_bit if bbox_bit is None else bbox_bit
        ell_alpha = dm.draw_prefs.ellipse_alpha if ell_alpha is None else ell_alpha

        # Make sure alpha in range [0,1]
        if ell_alpha > 1:
            ell_alpha = 1.0
        if ell_alpha < 0:
            ell_alpha = 0.0

        # Get color from colormap or overloaded parameter
        if color is None:
            color = plt.get_cmap("hsv")(float(axi_color) / len(dm.ax_list))[0:3]
            if axi_color == 0:
                color = [color[0], color[1] + 0.5, color[2]]

        # Axis We are drawing to.
        ax = dm.ax_list[axi]
        T_data = ax.transData  # data coordinates -> display coordinates
        # Data coordinates are chip coords

        if xy_bit or ell_bit or fsel != None:
            T_fpts = T_data if not in_image_bit else Affine2D(cm.cx2_T_chip2img(cx)) + T_data
            fpts = cm.get_fpts(cx)
            if fsel is None:
                fsel = range(len(fpts))
            # ---DEVHACK---
            # Randomly sample the keypoints. (Except be sneaky)
            elif fsel == "rand":
                # Get Relative Position
                minxy = fpts.min(0)[0:2]
                maxxy = fpts.max(0)[0:2]
                rel_pos = (fpts[:, 0] - minxy[0]) / (maxxy[0] - minxy[0])
                to_zero = 1 - np.abs(rel_pos - 0.5) / 0.5
                pdf = to_zero / to_zero.sum()
                # Transform Relative Position to Probabilities
                # making it more likely to pick a centerpoint
                fsel = np.random.choice(xrange(len(fpts)), size=88, replace=False, p=pdf)
            # ---/DEVHACK---
            # Plot ellipses
            if ell_bit and len(fpts) > 0 and len(fsel) > 0:
                ells = dm._get_fpt_ell_collection(fpts[fsel, :], T_fpts, ell_alpha, color)
                ax.add_collection(ells)
            # Plot xy points
            if xy_bit and len(fpts) > 0 and len(fsel) > 0:
                ax.plot(
                    fpts[fsel, 0],
                    fpts[fsel, 1],
                    "o",
                    markeredgecolor=color,
                    markerfacecolor=color,
                    transform=T_fpts,
                    markersize=2,
                )
        # ===
        if bbox_bit:
            # Draw Bounding Rectangle in Image Coords
            [rx, ry, rw, rh] = cm.cx2_roi[cx]
            rxy = (rx, ry)
            # Convert to Chip Coords if needbe
            T_bbox = T_data if in_image_bit else Affine2D(np.linalg.inv(cm.cx2_T_chip2img(cx))) + T_data
            bbox = Rectangle(rxy, rw, rh, transform=T_bbox)
            # Visual Properties
            bbox.set_fill(False)
            bbox.set_edgecolor(color)
            ax.add_patch(bbox)

            # Draw Text Annotation
            cid = cm.cx2_cid[cx]
            name = cm.cx2_name(cx)
            # Lower the value to .2 for the background color and set alpha=.7
            rgb_textFG = [1, 1, 1]
            hsv_textBG = colorsys.rgb_to_hsv(*color)[0:2] + (0.2,)
            rgb_textBG = colorsys.hsv_to_rgb(*hsv_textBG) + (0.7,)
            # Draw Orientation Backwards
            degrees = 0 if not in_image_bit else -cm.cx2_theta[cx] * 180 / np.pi
            txy = (0, rh) if not in_image_bit else (rx, ry + rh)

            chip_text = "name=" + name + "\n" + "cid=" + str(cid)
            ax.text(
                txy[0] + 1,
                txy[1] + 1,
                chip_text,
                horizontalalignment="left",
                verticalalignment="top",
                transform=T_data,
                rotation=degrees,
                color=rgb_textFG,
                backgroundcolor=rgb_textBG,
            )
        return fsel
开发者ID:Erotemic,项目名称:hotspotter,代码行数:104,代码来源:DrawManager.py


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