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


Python rcParams.update方法代码示例

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


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

示例1: set_pub_style

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def set_pub_style():
    """formatting helper function that can be used to save publishable figures"""
    set_figure_params('dynamo', background='white')
    matplotlib.use('cairo')
    matplotlib.rcParams.update({'font.size': 4})
    params = {'legend.fontsize': 4,
              'legend.handlelength': 0.5}
    matplotlib.rcParams.update(params)
    params = {'axes.labelsize': 6,
             'axes.titlesize':6,
             'xtick.labelsize':6,
             'ytick.labelsize':6,
             'axes.titlepad': 1,
             'axes.labelpad': 1
    }
    matplotlib.rcParams.update(params) 
开发者ID:aristoteleo,项目名称:dynamo-release,代码行数:18,代码来源:configuration.py

示例2: visualize_2D_trip

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def visualize_2D_trip(self,trip,tw_open,tw_close):
        plt.figure(figsize=(30,30))
        rcParams.update({'font.size': 22})
        # Plot cities
        colors = ['red'] # Depot is first city
        for i in range(len(tw_open)-1):
            colors.append('blue')
        plt.scatter(trip[:,0], trip[:,1], color=colors, s=200)
        # Plot tour
        tour=np.array(list(range(len(trip))) + [0])
        X = trip[tour, 0]
        Y = trip[tour, 1]
        plt.plot(X, Y,"--", markersize=100)
        # Annotate cities with TW
        tw_open = np.rint(tw_open)
        tw_close = np.rint(tw_close)
        time_window = np.concatenate((tw_open,tw_close),axis=1)
        for tw, (x, y) in zip(time_window,(zip(X,Y))):
            plt.annotate(tw,xy=(x, y))  
        plt.xlim(0,60)
        plt.ylim(0,60)
        plt.show()


    # Heatmap of permutations (x=cities; y=steps) 
开发者ID:MichelDeudon,项目名称:neural-combinatorial-optimization-rl-tensorflow,代码行数:27,代码来源:dataset.py

示例3: visualize_sampling

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def visualize_sampling(self,permutations):
        max_length = len(permutations[0])
        grid = np.zeros([max_length,max_length]) # initialize heatmap grid to 0
        transposed_permutations = np.transpose(permutations)
        for t, cities_t in enumerate(transposed_permutations): # step t, cities chosen at step t
            city_indices, counts = np.unique(cities_t,return_counts=True,axis=0)
            for u,v in zip(city_indices, counts):
                grid[t][u]+=v # update grid with counts from the batch of permutations
        # plot heatmap
        fig = plt.figure()
        rcParams.update({'font.size': 22})
        ax = fig.add_subplot(1,1,1)
        ax.set_aspect('equal')
        plt.imshow(grid, interpolation='nearest', cmap='gray')
        plt.colorbar()
        plt.title('Sampled permutations')
        plt.ylabel('Time t')
        plt.xlabel('City i')
        plt.show()

    # Heatmap of attention (x=cities; y=steps) 
开发者ID:MichelDeudon,项目名称:neural-combinatorial-optimization-rl-tensorflow,代码行数:23,代码来源:dataset.py

示例4: visualize_2D_trip

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def visualize_2D_trip(self, trip):
        plt.figure(figsize=(30,30))
        rcParams.update({'font.size': 22})

        # Plot cities
        plt.scatter(trip[:,0], trip[:,1], s=200)

        # Plot tour
        tour=np.array(list(range(len(trip))) + [0])
        X = trip[tour, 0]
        Y = trip[tour, 1]
        plt.plot(X, Y,"--", markersize=100)

        # Annotate cities with order
        labels = range(len(trip))
        for i, (x, y) in zip(labels,(zip(X,Y))):
            plt.annotate(i,xy=(x, y))  

        plt.xlim(0,100)
        plt.ylim(0,100)
        plt.show()


    # Heatmap of permutations (x=cities; y=steps) 
开发者ID:MichelDeudon,项目名称:neural-combinatorial-optimization-rl-tensorflow,代码行数:26,代码来源:dataset.py

示例5: visualize_sampling

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def visualize_sampling(self, permutations):
        max_length = len(permutations[0])
        grid = np.zeros([max_length,max_length]) # initialize heatmap grid to 0

        transposed_permutations = np.transpose(permutations)
        for t, cities_t in enumerate(transposed_permutations): # step t, cities chosen at step t
            city_indices, counts = np.unique(cities_t,return_counts=True,axis=0)
            for u,v in zip(city_indices, counts):
                grid[t][u]+=v # update grid with counts from the batch of permutations

        # plot heatmap
        fig = plt.figure()
        rcParams.update({'font.size': 22})
        ax = fig.add_subplot(1,1,1)
        ax.set_aspect('equal')
        plt.imshow(grid, interpolation='nearest', cmap='gray')
        plt.colorbar()
        plt.title('Sampled permutations')
        plt.ylabel('Time t')
        plt.xlabel('City i')
        plt.show() 
开发者ID:MichelDeudon,项目名称:neural-combinatorial-optimization-rl-tensorflow,代码行数:23,代码来源:dataset.py

示例6: plot_class_ROC

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def plot_class_ROC(fpr, tpr, roc_auc, class_idx, labels):
    from matplotlib import rcParams
    # Make room for xlabel which is otherwise cut off
    rcParams.update({'figure.autolayout': True})
    plt.figure()
    lw = 2
    plt.plot(fpr[class_idx], tpr[class_idx], color='darkorange',
             lw=lw, label='ROC curve (area = %0.2f)' % roc_auc[class_idx])
    plt.plot([0, 1], [0, 1], color='navy', lw=lw, linestyle='--')
    plt.xlim([0.0, 1.0])
    plt.ylim([0.0, 1.05])
    plt.xlabel('False Positive Rate')
    plt.ylabel('True Positive Rate')
    plt.title('Receiver operating characteristic of class {}'.format(labels[class_idx]))
    plt.legend(loc="lower right")
    plt.tight_layout() 
开发者ID:SalikLP,项目名称:classification-of-encrypted-traffic,代码行数:18,代码来源:utils.py

示例7: add_theme

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def add_theme(self, other, inplace=False):
        """Add themes together.

        Subclasses should not override this method.

        This will be called when adding two instances of class 'theme'
        together.
        A complete theme will annihilate any previous themes. Partial themes
        can be added together and can be added to a complete theme.
        """
        if other.complete:
            return other

        theme_copy = self if inplace else deepcopy(self)
        theme_copy.themeables.update(deepcopy(other.themeables))
        return theme_copy 
开发者ID:has2k1,项目名称:plotnine,代码行数:18,代码来源:theme.py

示例8: visualize_attention

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def visualize_attention(self,attention):
        # plot heatmap
        fig = plt.figure()
        rcParams.update({'font.size': 22})
        ax = fig.add_subplot(1,1,1)
        ax.set_aspect('equal')
        plt.imshow(attention, interpolation='nearest', cmap='hot')
        plt.colorbar()
        plt.title('Attention distribution')
        plt.ylabel('Step t')
        plt.xlabel('Attention_t')
        plt.show() 
开发者ID:MichelDeudon,项目名称:neural-combinatorial-optimization-rl-tensorflow,代码行数:14,代码来源:dataset.py

示例9: plot_metric_graph

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def plot_metric_graph(x_list, y_list, x_label="Datapoints", y_label="Accuracy",
                          title='Metric list', save=False):
    from matplotlib import rcParams
    # Make room for xlabel which is otherwise cut off
    rcParams.update({'figure.autolayout': True})
    plt.figure()
    plt.plot(x_list, y_list, label="90/10 split")
    # plt.plot(x_list2, y_list2, label="Seperate testset")
    # Calculate min and max of y scale
    ymin = np.min(y_list)
    ymin = np.floor(ymin * 10) / 10
    ymax = np.max(y_list)
    ymax = np.ceil(ymax * 10) / 10
    plt.ylim(ymin, ymax)
    plt.title("{0}".format(title))
    plt.tight_layout()
    plt.ylabel(y_label)
    plt.xlabel(x_label)
    # plt.legend()
    if save:
        i = 0
        filename = "{}".format(title)
        while os.path.exists('{}{:d}.png'.format(filename, i)):
            i += 1
        plt.savefig('{}{:d}.png'.format(filename, i), dpi=300)
    plt.draw()
    # plt.gcf().clear() 
开发者ID:SalikLP,项目名称:classification-of-encrypted-traffic,代码行数:29,代码来源:utils.py

示例10: plot_multi_ROC

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def plot_multi_ROC(fpr, tpr, roc_auc, num_classes, labels, micro=True, macro=True):
    from matplotlib import rcParams
    # Make room for xlabel which is otherwise cut off
    rcParams.update({'figure.autolayout': True})
    # Plot all ROC curves
    plt.figure()
    lw = 2
    if micro:
        plt.plot(fpr["micro"], tpr["micro"],
             label='micro-average ROC curve (area = {0:0.2f})'
                   ''.format(roc_auc["micro"]),
             color='deeppink', linestyle=':', linewidth=4)
    if macro:
        plt.plot(fpr["macro"], tpr["macro"],
             label='macro-average ROC curve (area = {0:0.2f})'
                   ''.format(roc_auc["macro"]),
             color='navy', linestyle=':', linewidth=4)
    color_map = {0: '#487fff', 1: '#2ee3ff', 2: '#4eff4e', 3: '#ffca43', 4: '#ff365e', 5: '#d342ff', 6: '#626663'}
    # colors = cycle(['aqua', 'darkorange', 'cornflowerblue'])
    for i in range(num_classes):
        plt.plot(fpr[i], tpr[i], color=color_map[i], lw=lw,
                 label='ROC curve of {0} (area = {1:0.2f})'
                       ''.format(labels[i], roc_auc[i]))

    plt.plot([0, 1], [0, 1], 'k--', lw=lw)
    plt.xlim([0.0, 1.0])
    plt.ylim([0.0, 1.05])
    plt.xlabel('False Positive Rate')
    plt.ylabel('True Positive Rate')
    plt.title('Receiver operating characteristic of all classes')
    plt.legend(loc="lower right")
    plt.tight_layout() 
开发者ID:SalikLP,项目名称:classification-of-encrypted-traffic,代码行数:34,代码来源:utils.py

示例11: set_rcParams_defaults

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def set_rcParams_defaults():
    """Reset `matplotlib.rcParams` to defaults."""
    rcParams.update(matplotlib.rcParamsDefault) 
开发者ID:theislab,项目名称:scanpy,代码行数:5,代码来源:_rcmod.py

示例12: set_rcParams_defaults

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def set_rcParams_defaults():
    """Reset `matplotlib.rcParams` to defaults."""
    from matplotlib import rcParamsDefault

    rcParams.update(rcParamsDefault)


# ------------------------------------------------------------------------------
# Private global variables & functions
# ------------------------------------------------------------------------------ 
开发者ID:theislab,项目名称:scvelo,代码行数:12,代码来源:settings.py

示例13: rcParams

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def rcParams(self):
        """
        Return rcParams dict for this theme.

        Notes
        -----
        Subclasses should not need to override this method method as long as
        self._rcParams is constructed properly.

        rcParams are used during plotting. Sometimes the same theme can be
        achieved by setting rcParams before plotting or a apply
        after plotting. The choice of how to implement it is is a matter of
        convenience in that case.

        There are certain things can only be themed after plotting. There
        may not be an rcParam to control the theme or the act of plotting
        may cause an entity to come into existence before it can be themed.

        """

        try:
            rcParams = deepcopy(self._rcParams)
        except NotImplementedError:
            # deepcopy raises an error for objects that are drived from or
            # composed of matplotlib.transform.TransformNode.
            # Not desirable, but probably requires upstream fix.
            # In particular, XKCD uses matplotlib.patheffects.withStrok
            rcParams = copy(self._rcParams)

        for th in self.themeables.values():
            rcParams.update(th.rcParams)
        return rcParams 
开发者ID:has2k1,项目名称:plotnine,代码行数:34,代码来源:theme.py

示例14: dyn_theme

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def dyn_theme(background="white"):
    # https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/mpl-data/stylelib/dark_background.mplstyle

    if background == "black":
        rcParams.update(
            {
                "lines.color": "w",
                "patch.edgecolor": "w",
                "text.color": "w",
                "axes.facecolor": background,
                "axes.edgecolor": "white",
                "axes.labelcolor": "w",
                "xtick.color": "w",
                "ytick.color": "w",
                "figure.facecolor": background,
                "figure.edgecolor": background,
                "savefig.facecolor": background,
                "savefig.edgecolor": background,
                "grid.color": "w",
                "axes.grid": False,
            }
        )
    else:
        rcParams.update(
            {
                "lines.color": "k",
                "patch.edgecolor": "k",
                "text.color": "k",
                "axes.facecolor": background,
                "axes.edgecolor": "black",
                "axes.labelcolor": "k",
                "xtick.color": "k",
                "ytick.color": "k",
                "figure.facecolor": background,
                "figure.edgecolor": background,
                "savefig.facecolor": background,
                "savefig.edgecolor": background,
                "grid.color": "k",
                "axes.grid": False,
            }
        ) 
开发者ID:aristoteleo,项目名称:dynamo-release,代码行数:43,代码来源:configuration.py

示例15: reset_rcParams

# 需要导入模块: from matplotlib import rcParams [as 别名]
# 或者: from matplotlib.rcParams import update [as 别名]
def reset_rcParams():
    """Reset `matplotlib.rcParams` to defaults."""
    from matplotlib import rcParamsDefault

    rcParams.update(rcParamsDefault) 
开发者ID:aristoteleo,项目名称:dynamo-release,代码行数:7,代码来源:configuration.py


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