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


Python matplotlib.cycler方法代码示例

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


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

示例1: test_cn

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import cycler [as 别名]
def test_cn():
    matplotlib.rcParams['axes.prop_cycle'] = cycler('color',
                                                    ['blue', 'r'])
    assert mcolors.to_hex("C0") == '#0000ff'
    assert mcolors.to_hex("C1") == '#ff0000'

    matplotlib.rcParams['axes.prop_cycle'] = cycler('color',
                                                    ['xkcd:blue', 'r'])
    assert mcolors.to_hex("C0") == '#0343df'
    assert mcolors.to_hex("C1") == '#ff0000'

    matplotlib.rcParams['axes.prop_cycle'] = cycler('color', ['8e4585', 'r'])

    assert mcolors.to_hex("C0") == '#8e4585'
    # if '8e4585' gets parsed as a float before it gets detected as a hex
    # colour it will be interpreted as a very large number.
    # this mustn't happen.
    assert mcolors.to_rgb("C0")[0] != np.inf 
开发者ID:holzschu,项目名称:python3_ios,代码行数:20,代码来源:test_colors.py

示例2: test_default_color_cycle

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import cycler [as 别名]
def test_default_color_cycle(self):
        import matplotlib.pyplot as plt
        import cycler
        colors = list('rgbk')
        plt.rcParams['axes.prop_cycle'] = cycler.cycler('color', colors)

        df = DataFrame(randn(5, 3))
        ax = df.plot()

        expected = self._unpack_cycler(plt.rcParams)[:3]
        self._check_colors(ax.get_lines(), linecolors=expected) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:13,代码来源:test_frame.py

示例3: test_rcParams_bar_colors

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import cycler [as 别名]
def test_rcParams_bar_colors(self):
        import matplotlib as mpl
        color_tuples = [(0.9, 0, 0, 1), (0, 0.9, 0, 1), (0, 0, 0.9, 1)]
        with mpl.rc_context(
                rc={'axes.prop_cycle': mpl.cycler("color", color_tuples)}):
            barplot = pd.DataFrame([[1, 2, 3]]).plot(kind="bar")
        assert color_tuples == [c.get_facecolor() for c in barplot.patches] 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:9,代码来源:test_frame.py

示例4: test_default_color_cycle

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import cycler [as 别名]
def test_default_color_cycle(self):
        import matplotlib.pyplot as plt
        colors = list('rgbk')
        if self.mpl_ge_1_5_0:
            import cycler
            plt.rcParams['axes.prop_cycle'] = cycler.cycler('color', colors)
        else:
            plt.rcParams['axes.color_cycle'] = colors

        df = DataFrame(randn(5, 3))
        ax = df.plot()

        expected = self._maybe_unpack_cycler(plt.rcParams)[:3]
        self._check_colors(ax.get_lines(), linecolors=expected) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:16,代码来源:test_frame.py

示例5: test_rcParams_bar_colors

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import cycler [as 别名]
def test_rcParams_bar_colors(self):
        import matplotlib as mpl
        color_tuples = [(0.9, 0, 0, 1), (0, 0.9, 0, 1), (0, 0, 0.9, 1)]
        try:  # mpl 1.5
            with mpl.rc_context(
                    rc={'axes.prop_cycle': mpl.cycler("color", color_tuples)}):
                barplot = pd.DataFrame([[1, 2, 3]]).plot(kind="bar")
        except (AttributeError, KeyError):  # mpl 1.4
            with mpl.rc_context(rc={'axes.color_cycle': color_tuples}):
                barplot = pd.DataFrame([[1, 2, 3]]).plot(kind="bar")
        assert color_tuples == [c.get_facecolor() for c in barplot.patches] 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:13,代码来源:test_frame.py

示例6: __init__

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import cycler [as 别名]
def __init__(self, *args, **kwargs):
        plt.style.use('dark_background')
        mpl.rcParams['toolbar'] = 'None'
        mpl.rcParams['axes.prop_cycle'] = mpl.cycler(color=[DEFAULT_COLOR])
        self.figure = plt.figure()
        self.subplots() 
开发者ID:cortex-lab,项目名称:phy,代码行数:8,代码来源:plot.py

示例7: _makedos

# 需要导入模块: import matplotlib [as 别名]
# 或者: from matplotlib import cycler [as 别名]
def _makedos(self, ax, dos_plotter, dos_options, dos_label=None,
                 plot_legend=True):
        """This is basically the same as the SDOSPlotter get_plot function."""

        # don't use first 4 colours; these are the band structure line colours
        cycle = cycler(
            'color', rcParams['axes.prop_cycle'].by_key()['color'][4:])
        with context({'axes.prop_cycle': cycle}):
            plot_data = dos_plotter.dos_plot_data(**dos_options)

        mask = plot_data['mask']
        energies = plot_data['energies'][mask]
        lines = plot_data['lines']
        spins = [Spin.up] if len(lines[0][0]['dens']) == 1 else \
            [Spin.up, Spin.down]

        # disable y ticks for DOS panel
        ax.tick_params(axis='y', which='both', right=False)

        for line_set in plot_data['lines']:
            for line, spin in it.product(line_set, spins):
                if spin == Spin.up:
                    label = line['label']
                    densities = line['dens'][spin][mask]
                else:
                    label = ""
                    densities = -line['dens'][spin][mask]
                ax.fill_betweenx(energies, densities, 0, lw=0,
                                 facecolor=line['colour'],
                                 alpha=line['alpha'])
                ax.plot(densities, energies, label=label,
                        color=line['colour'])

            # x and y axis reversed versus normal dos plotting
            ax.set_ylim(dos_options['xmin'], dos_options['xmax'])
            ax.set_xlim(plot_data['ymin'], plot_data['ymax'])

            if dos_label is not None:
                ax.set_xlabel(dos_label)

        ax.set_xticklabels([])
        if plot_legend:
            ax.legend(loc=2, frameon=False, ncol=1, bbox_to_anchor=(1., 1.)) 
开发者ID:SMTG-UCL,项目名称:sumo,代码行数:45,代码来源:bs_plotter.py


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