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


Python PatchCollection.set_hatch方法代码示例

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


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

示例1: PlotConductors

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

#.........这里部分代码省略.........
        # Iterate through all conductor lists in the solver
        for key in solver.installedconductorlists:
            # Iterate through all conductor objects
            for conductor in solver.installedconductorlists[key]:
                # Perform check to make sure this is a conductor the code knows how to handle
                for obj_type in self.conductor_types:
                    if isinstance(conductor, getattr(field_solvers.generateconductors, obj_type)):
                        if conductor.permittivity is None:
                            self.conductors.append(self.set_rectangle_patch(conductor))
                            self.voltages.append(conductor.voltage)
                        if conductor.permittivity is not None:
                            self.dielectrics.append(self.set_rectangle_patch(conductor, dielectric=True))
                            self.permittivities.append(conductor.permittivity)

    def conductor_collection(self):
        # TODO: Once dielectrics register with solver add in loop to append them to dielectric array
        if not self.plot_axes:
            self.create_axes()

        if len(self.voltages) > 0:
            self.set_collection_colors(self.conductor_patch_colors, self.voltages, self.map)

            # Assign patches for conductors to the plot axes
            self.conductor_patches = PatchCollection(self.conductors)
            self.conductor_patches.set_color(self.conductor_patch_colors)
            self.plot_axes.add_collection(self.conductor_patches)

        if len(self.permittivities) > 0:
            self.set_collection_colors(self.dielectric_patch_colors, self.permittivities, plt.cm.viridis)

            # Assign patches for dielectrics to the plot axes
            self.dielectric_patches = PatchCollection(self.dielectrics)
            self.dielectric_patches.set_color(self.dielectric_patch_colors)
            self.dielectric_patches.set_hatch('//')
            self.plot_axes.add_collection(self.dielectric_patches)

            # Setup the legend and set data for legend axes
            self.create_legend()
        if len(self.voltages) > 0:
            cond_legend = self.legend_axes.legend(handles=self.conductor_legend_handles,
                                    bbox_to_anchor=self.legend_anchor,
                                    borderaxespad=0.,
                                    fontsize=self.legend_fontsize,
                                    title='Voltage (V)')
            self.legend_axes.add_artist(cond_legend)
        if len(self.permittivities) > 0:
            diel_legend = self.legend_axes.legend(handles=self.dielectric_legend_handles,
                                    bbox_to_anchor=(self.legend_anchor[0] + 0.05, self.legend_anchor[1] - 0.2),
                                    borderaxespad=0.,
                                    fontsize=self.legend_fontsize,
                                    title='   Relative\nPermittivity')
            self.legend_axes.add_artist(diel_legend)

    def set_collection_colors(self, color_collection, color_values, map):
        # Wanted color scaling to always be red for negative and blue for positive (assuming bl-r colormap)
        # Created custom linear scaling to using halves of color map for +/- consistently, even if only one sign present

        if self.variable_voltage_color:
            # Min/maxes for linear mapping of voltage to colormap
            negative_min = min(color_values)
            try:
                negative_max = max([i for i in color_values if i < 0.])
            except ValueError:
                negative_max = 0.
            try:
                positive_min = min([i for i in color_values if i > 0.])
开发者ID:radiasoft,项目名称:rswarp,代码行数:70,代码来源:ConductorPlot.py


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