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


Python colors.hex2color方法代码示例

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


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

示例1: call_back_plane_move_changes

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import hex2color [as 别名]
def call_back_plane_move_changes(self, indices):
        df_changes = self.model._orientations.df.loc[np.atleast_1d(indices).astype(int)][['X', 'Y', 'Z',
                                                                                          'G_x', 'G_y', 'G_z', 'id']]
        for index, new_values_df in df_changes.iterrows():
            new_center = new_values_df[['X', 'Y', 'Z']].values
            new_normal = new_values_df[['G_x', 'G_y', 'G_z']].values
            new_source = vtk.vtkPlaneSource()
            new_source.SetCenter(new_center)
            new_source.SetNormal(new_normal)
            new_source.Update()

            plane1 = self.orientations_widgets[index]
            #  plane1.SetInputData(new_source.GetOutput())
            plane1.SetNormal(new_normal)
            plane1.SetCenter(new_center[0], new_center[1], new_center[2])

            _color_lot = self._get_color_lot(is_faults=True, is_basement=False, index='id')
            plane1.GetPlaneProperty().SetColor(mcolors.hex2color(_color_lot[int(new_values_df['id'])]))
            plane1.GetHandleProperty().SetColor(mcolors.hex2color(_color_lot[int(new_values_df['id'])])) 
开发者ID:cgre-aachen,项目名称:gempy,代码行数:21,代码来源:vista_aux.py

示例2: lighten_hex

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import hex2color [as 别名]
def lighten_hex(hexcolor, amount):
    import plottool_ibeis as pt
    import matplotlib.colors as colors
    return pt.color_funcs.lighten_rgb(colors.hex2color(hexcolor), amount) 
开发者ID:Erotemic,项目名称:ibeis,代码行数:6,代码来源:specialdraw.py

示例3: _get_heatmap_row_colors

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import hex2color [as 别名]
def _get_heatmap_row_colors(meta_df, index):
    cnc_to_color = utils.load_color_scheme(config.color_scheme_path)
    for key, value in cnc_to_color.items():
        rgb = hex2color(value)
        cnc_to_color[key] = rgb + (1.0,)
        cnc_to_color[key + ' (Normal)'] = rgb + (.5,)
    row_colors = meta_df['cnc'].map(cnc_to_color).loc[index]
    return row_colors, cnc_to_color 
开发者ID:ratschlab,项目名称:pancanatlas_code_public,代码行数:10,代码来源:sf_heatmap.py

示例4: rgb_from_name

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import hex2color [as 别名]
def rgb_from_name(color_name):
    """Get a rgb color from a color name."""
    rgb_norm = mcolor.hex2color(mcolor.cnames[color_name])
    rgb = [int(x * 255) for x in rgb_norm]
    return rgb 
开发者ID:partofthething,项目名称:infopanel,代码行数:7,代码来源:colors.py

示例5: hex_to_int

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import hex2color [as 别名]
def hex_to_int(hex_colors):
    rgb_colors = np.array([colors.hex2color(c) for c in hex_colors])
    rgb_colors = np.multiply(rgb_colors, 255).astype(np.int)
    return rgb_colors 
开发者ID:noureldien,项目名称:videograph,代码行数:6,代码来源:plot_utils.py

示例6: tatarize

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import hex2color [as 别名]
def tatarize(n):
    """
    Return n-by-3 RGB color matrix using the "tatarize" color alphabet (n <= 269)
    :param n:
    :return:
    """

    with open(os.path.expanduser('~/.seqc/tools/tatarize_269.txt')) as f:
        s = f.read().split('","')
    s[0] = s[0].replace('{"', '')
    s[-1] = s[-1].replace('"}', '')
    s = [hex2color(s) for s in s]
    return s[:n] 
开发者ID:ambrosejcarr,项目名称:seqc,代码行数:15,代码来源:plot.py

示例7: call_back_sphere_move_changes

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import hex2color [as 别名]
def call_back_sphere_move_changes(self, indices):
        df_changes = self.model._surface_points.df.loc[np.atleast_1d(indices)][['X', 'Y', 'Z', 'id']]
        for index, df_row in df_changes.iterrows():
            new_center = df_row[['X', 'Y', 'Z']].values

            # Update renderers
            s1 = self.surface_points_widgets[index]
            r_f = s1.GetRadius() * 2
            s1.PlaceWidget(new_center[0] - r_f, new_center[0] + r_f,
                           new_center[1] - r_f, new_center[1] + r_f,
                           new_center[2] - r_f, new_center[2] + r_f)

            _color_lot = self._get_color_lot(is_faults=True, is_basement=False, index='id')
            s1.GetSphereProperty().SetColor(mcolors.hex2color(_color_lot[(df_row['id'])])) 
开发者ID:cgre-aachen,项目名称:gempy,代码行数:16,代码来源:vista_aux.py

示例8: call_back_sphere_move_changes

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import hex2color [as 别名]
def call_back_sphere_move_changes(self, indices):
        df_changes = self.model._surface_points.df.loc[np.atleast_1d(indices)][['X', 'Y', 'Z', 'id']]
        for index, df_row in df_changes.iterrows():
            new_center = df_row[['X', 'Y', 'Z']].values

            # Update renderers
            s1 = self.s_widget.loc[index, 'val']
            r_f = s1.GetRadius() * 2
            s1.PlaceWidget(new_center[0] - r_f, new_center[0] + r_f,
                           new_center[1] - r_f, new_center[1] + r_f,
                           new_center[2] - r_f, new_center[2] + r_f)

            s1.GetSphereProperty().SetColor(mcolors.hex2color(self._color_lot[df_row['id']])) 
开发者ID:cgre-aachen,项目名称:gempy,代码行数:15,代码来源:_vista.py

示例9: create_sphere

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import hex2color [as 别名]
def create_sphere(self, X, Y, Z, fn, n_sphere=0, n_render=0, n_index=0, r=0.03):
        """
        Method to create the sphere that represent the surface_points points
        Args:
            X: X coord
            Y: Y coord
            Z: Z corrd
            fn (int): id
            n_sphere (int): Number of the sphere
            n_render (int): Number of the render where the sphere belongs
            n_index (int): index value in the PandasDataframe of InupData.surface_points
            r (float): radius of the sphere

        Returns:
            vtk.vtkSphereWidget
        """
        s = vtk.vtkSphereWidget()
        s.SetInteractor(self.interactor)
        s.SetRepresentationToSurface()
        s.SetPriority(2)
        Z = Z * self.ve
        s.r_f = self._e_d_avrg * r
        s.PlaceWidget(X - s.r_f, X + s.r_f, Y - s.r_f, Y + s.r_f, Z - s.r_f, Z + s.r_f)
        s.GetSphereProperty().SetColor(mcolors.hex2color(self.geo_model._surfaces.df.set_index('id')['color'][fn]))#self.C_LOT[fn])

        s.SetCurrentRenderer(self.ren_list[n_render])
        s.n_sphere = n_sphere
        s.n_render = n_render
        s.index = n_index
        s.AddObserver("EndInteractionEvent", self.sphereCallback)  # EndInteractionEvent
        s.AddObserver("InteractionEvent", self.Callback_camera_reset)

        s.On()

        return s 
开发者ID:cgre-aachen,项目名称:gempy,代码行数:37,代码来源:visualization_3d.py

示例10: set_geological_map

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import hex2color [as 别名]
def set_geological_map(self):
        assert self.geo_model.solutions.geological_map is not None, 'Geological map not computed. First' \
                                                                    'set active the topography grid'
        arr_ = np.empty((0, 3), dtype='int')

        # Convert hex colors to rgb
        for idx, val in self.geo_model._surfaces.df['color'].iteritems():
            rgb = (255 * np.array(mcolors.hex2color(val)))
            arr_ = np.vstack((arr_, rgb))

        sel = np.round(self.geo_model.solutions.geological_map[0]).astype(int)[0]
        nv = numpy_to_vtk(arr_[sel - 1], array_type=3)
        self._topography_delauny.GetOutput().GetPointData().SetScalars(nv) 
开发者ID:cgre-aachen,项目名称:gempy,代码行数:15,代码来源:visualization_3d.py

示例11: SphereCallbak_move_changes

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import hex2color [as 别名]
def SphereCallbak_move_changes(self, indices):
       # print(indices)
        df_changes = self.geo_model._surface_points.df.loc[np.atleast_1d(indices)][['X', 'Y', 'Z', 'id']]
        for index, df_row in df_changes.iterrows():
            new_center = df_row[['X', 'Y', 'Z']].values

            # Update renderers
            s1 = self.s_rend_1.loc[index, 'val']

            s1.PlaceWidget(new_center[0] - s1.r_f, new_center[0] + s1.r_f,
                           new_center[1] - s1.r_f, new_center[1] + s1.r_f,
                           new_center[2] - s1.r_f, new_center[2] + s1.r_f)

            s1.GetSphereProperty().SetColor(mcolors.hex2color(
                self.geo_model._surfaces.df.set_index('id')['color'][df_row['id']]))#self.C_LOT[df_row['id']])

            s2 = self.s_rend_2.loc[index, 'val']
            s2.PlaceWidget(new_center[0] - s2.r_f, new_center[0] + s2.r_f,
                           new_center[1] - s2.r_f, new_center[1] + s2.r_f,
                           new_center[2] - s2.r_f, new_center[2] + s2.r_f)

            s2.GetSphereProperty().SetColor(mcolors.hex2color(
                self.geo_model._surfaces.df.set_index('id')['color'][df_row['id']]))

            s3 = self.s_rend_3.loc[index, 'val']
            s3.PlaceWidget(new_center[0] - s3.r_f, new_center[0] + s3.r_f,
                           new_center[1] - s3.r_f, new_center[1] + s3.r_f,
                           new_center[2] - s3.r_f, new_center[2] + s3.r_f)

            s3.GetSphereProperty().SetColor(mcolors.hex2color(
                self.geo_model._surfaces.df.set_index('id')['color'][df_row['id']]))

            s4 = self.s_rend_4.loc[index, 'val']
            s4.PlaceWidget(new_center[0] - s4.r_f, new_center[0] + s4.r_f,
                           new_center[1] - s4.r_f, new_center[1] + s4.r_f,
                           new_center[2] - s4.r_f, new_center[2] + s4.r_f)

            s4.GetSphereProperty().SetColor(mcolors.hex2color(
                self.geo_model._surfaces.df.set_index('id')['color'][df_row['id']])) 
开发者ID:cgre-aachen,项目名称:gempy,代码行数:41,代码来源:visualization_3d.py

示例12: plot_topography

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import hex2color [as 别名]
def plot_topography(self, topography = None, scalars='geo_map', **kwargs):
        """

        Args:
            topography: gp Topography object, np.array or None
            scalars:
            **kwargs:

        Returns:

        """
        if topography is None:
            topography = self.model._grid.topography.values
        rgb = False

        # Create vtk object
        cloud = pv.PolyData(topography)

        # Set scalar values
        if scalars == 'geo_map':
            arr_ = np.empty((0, 3), dtype='int')

            # Convert hex colors to rgb
            for val in list(self._color_lot):
                rgb = (255 * np.array(mcolors.hex2color(val)))
                arr_ = np.vstack((arr_, rgb))

            sel = np.round(self.model.solutions.geological_map[0]).astype(int)[0]
          #  print(arr_)
          #  print(sel)

            scalars_val = numpy_to_vtk(arr_[sel-1], array_type=3)
            cm = None
            rgb = True

        elif scalars == 'topography':
            scalars_val = topography[:, 2]
            cm = 'terrain'

        elif type(scalars) is np.ndarray:
            scalars_val = scalars
            scalars = 'custom'
            cm = 'terrain'
        else:
            raise AttributeError()

        topo_actor = self.p.add_mesh(cloud.delaunay_2d(), scalars=scalars_val, cmap=cm, rgb=rgb, **kwargs)
        self.vista_topo_actors[scalars] = topo_actor
        return topo_actor 
开发者ID:cgre-aachen,项目名称:gempy,代码行数:51,代码来源:_vista.py

示例13: create_foliation

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import hex2color [as 别名]
def create_foliation(self, X, Y, Z, fn,
                         Gx, Gy, Gz,
                         n_plane=0, n_render=0, n_index=0, alpha=0.5):
        """
        Method to create a plane given a foliation

        Args:
            X : X coord
            Y: Y coord
            Z: Z coord
            fn (int): id
            Gx (str): Component of the gradient x
            Gy (str): Component of the gradient y
            Gz (str): Component of the gradient z
            n_plane (int): Number of the plane
            n_render (int): Number of the render where the plane belongs
            n_index (int): index value in the PandasDataframe of InupData.surface_points
            alpha: Opacity of the plane

        Returns:
            vtk.vtkPlaneWidget
        """

        Z = Z * self.ve

        d = vtk.vtkPlaneWidget()
        d.SetInteractor(self.interactor)
        d.SetRepresentationToSurface()

        # Position
        source = vtk.vtkPlaneSource()

        source.SetNormal(Gx, Gy, Gz)
        source.SetCenter(X, Y, Z)
        a, b, c, d_, e, f = self.extent

        source.SetPoint1(X+self._e_dx*.01, Y-self._e_dy*.01, Z)
        source.SetPoint2(X-self._e_dx*.01, Y+self._e_dy*.01, Z)
        source.Update()
        d.SetInputData(source.GetOutput())
        d.SetHandleSize(.05)
        min_extent = np.min([self._e_dx, self._e_dy, self._e_dz])
        d.SetPlaceFactor(0.1)

        d.PlaceWidget(a, b, c, d_, e, f)
        d.SetNormal(Gx, Gy, Gz)
        d.SetCenter(X, Y, Z)
        d.GetPlaneProperty().SetColor(mcolors.hex2color(self.geo_model._surfaces.df.set_index('id')['color'][fn]))#self.C_LOT[fn])
        d.GetHandleProperty().SetColor(mcolors.hex2color(self.geo_model._surfaces.df.set_index('id')['color'][fn]))#self.C_LOT[fn])
        d.GetHandleProperty().SetOpacity(alpha)
        d.SetCurrentRenderer(self.ren_list[n_render])
        d.n_plane = n_plane
        d.n_render = n_render
        d.index = n_index
        d.AddObserver("EndInteractionEvent", self.planesCallback)
        d.AddObserver("InteractionEvent", self.Callback_camera_reset)

        d.On()

        return d 
开发者ID:cgre-aachen,项目名称:gempy,代码行数:62,代码来源:visualization_3d.py

示例14: planesCallback_move_changes

# 需要导入模块: from matplotlib import colors [as 别名]
# 或者: from matplotlib.colors import hex2color [as 别名]
def planesCallback_move_changes(self, indices):
        df_changes = self.geo_model._orientations.df.loc[np.atleast_1d(indices)][['X', 'Y', 'Z', 'G_x', 'G_y', 'G_z', 'id']]
        for index, new_values_df in df_changes.iterrows():
            new_center = new_values_df[['X', 'Y', 'Z']].values
            new_normal = new_values_df[['G_x', 'G_y', 'G_z']].values
            new_source = vtk.vtkPlaneSource()
            new_source.SetCenter(new_center)
            new_source.SetNormal(new_normal)
            new_source.Update()

            plane1 = self.o_rend_1.loc[index, 'val']
          #  plane1.SetInputData(new_source.GetOutput())
            plane1.SetNormal(new_normal)
            plane1.SetCenter(new_center[0], new_center[1], new_center[2])
            plane1.GetPlaneProperty().SetColor(mcolors.hex2color(
                self.geo_model._surfaces.df.set_index('id')['color'][new_values_df['id']]))#self.C_LOT[new_values_df['id']])
            plane1.GetHandleProperty().SetColor(mcolors.hex2color(
                self.geo_model._surfaces.df.set_index('id')['color'][new_values_df['id']]))

            plane2 = self.o_rend_2.loc[index, 'val']
            plane2.SetInputData(new_source.GetOutput())
            plane2.SetNormal(new_normal)
            plane2.SetCenter(new_center[0], new_center[1], new_center[2])
            plane2.GetPlaneProperty().SetColor(mcolors.hex2color(
                self.geo_model._surfaces.df.set_index('id')['color'][new_values_df['id']]))
            plane2.GetHandleProperty().SetColor(mcolors.hex2color(
                self.geo_model._surfaces.df.set_index('id')['color'][new_values_df['id']]))

            plane3 = self.o_rend_3.loc[index, 'val']
            plane3.SetInputData(new_source.GetOutput())
            plane3.SetNormal(new_normal)
            plane3.SetCenter(new_center[0], new_center[1], new_center[2])
            plane3.GetPlaneProperty().SetColor(mcolors.hex2color(
                self.geo_model._surfaces.df.set_index('id')['color'][new_values_df['id']]))
            plane3.GetHandleProperty().SetColor(mcolors.hex2color(
                self.geo_model._surfaces.df.set_index('id')['color'][new_values_df['id']]))

            plane4 = self.o_rend_4.loc[index, 'val']
            plane4.SetInputData(new_source.GetOutput())
            plane4.SetNormal(new_normal)
            plane4.SetCenter(new_center[0], new_center[1], new_center[2])
            plane4.GetPlaneProperty().SetColor(mcolors.hex2color(
                self.geo_model._surfaces.df.set_index('id')['color'][new_values_df['id']]))
            plane4.GetHandleProperty().SetColor(mcolors.hex2color(
                self.geo_model._surfaces.df.set_index('id')['color'][new_values_df['id']])) 
开发者ID:cgre-aachen,项目名称:gempy,代码行数:47,代码来源:visualization_3d.py


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