我可以在 rcParams 中设置脊椎和刻度线吗? [英] Can I set spine and ticks in rcParams?

查看:75
本文介绍了我可以在 rcParams 中设置脊椎和刻度线吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我倾向于在Matplotlib(v1.3.1)图中使用以下轴选项:

I tend to use the following axes options in my Matplotlib (v1.3.1) plots:

        ax.spines["top"].set_visible(False)  
        ax.spines["bottom"].set_visible(True)  
        ax.spines["right"].set_visible(False)  
        ax.spines["left"].set_visible(True)  

        ax.get_xaxis().tick_bottom()  
        ax.get_yaxis().tick_left()  

        ax.tick_params(axis="both", which="both", bottom="off", top="off",  
                labelbottom="on", left="off", right="off", labelleft="on")  

这在抓取当前轴后工作正常,但我想知道是否可以通过在 rcParams 中进行设置来实现所有这些默认行为?

This works fine after grabbing the current axis, but I was wondering whether I could make all this default behaviour by setting things in rcParams?

推荐答案

正如ImportanceOfBeingErnest的评论中提到的那样,现在可以做到这一点:

As mentioned in ImportanceOfBeingErnest's comment, this is now possible:

plt.rcParams['axes.spines.top'] = False
plt.rcParams['axes.spines.bottom'] = False
plt.rcParams['axes.spines.left'] = False
plt.rcParams['axes.spines.right'] = False

对于多个 rcParams ,请使用 dict :

plt.rcParams.update({'axes.spines.top': False, 'axes.spines.right': False})

这篇关于我可以在 rcParams 中设置脊椎和刻度线吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆