如何在seaborn pairplot中更改轴标签和值的大小

时间:2017-07-20 03:23:33

标签: python seaborn

我使用以下代码在seaborn中创建了一个配对图:

export class CreatePostForm extends React.Component {

    constructor(props) {
        super(props);

        this.state = {
            postBody : "",
            user: this.props.auth.user
        };

        this.onSubmit = this.onSubmit.bind(this);
        this.onChange = this.onChange.bind(this);
    }

    onChange(e) {
        this.setState({
            [e.target.name] : e.target.value
        });
    }

    onSubmit(e) {
        e.preventDefault();

        this.props.createPostRequest(this.state).then(
            () => {
                this.props.loadPosts();
            })
    }

    render() {

        return (
            <div className="create-post-inner col-md-12">
                <form id="createPost" onSubmit={ this.onSubmit } >
                    <textarea value={this.state.postBody} className="form-control postInput" name="postBody" onChange={ this.onChange } placeholder="Write something on this page..." >
                    </textarea>
                    <input type="submit" className="submit btn btn-primary" />
                </form>
            </div>
        );
    }
}

得到这个情节:

enter image description here

字体很小,我试图弄清楚如何增加尺寸。我在documentation中看到了一个可能是我正在寻找的参数: plot_kws 这是一个字典,但我如何找出可用的密钥以及它们的作用?

所以我有两个问题。首先,是如何阅读文档,以便我可以弄清楚这个字典的键是什么。其次,是如何增加该图的y轴标签的字体大小。

2 个答案:

答案 0 :(得分:1)

原来,为了改变x和y轴标签的大小,我需要调用 set_context 并将字典传递给 rc 参数。当我在 pairplot

的调用上方添加此行时
sns.set_context("paper", rc={"axes.labelsize":36})

我得到这个情节:

enter image description here

这是一项改进(如果仔细观察),但我现在正试图弄清楚如何增加刻度标签的大小。

答案 1 :(得分:0)

使用所有参数调整图形大小。

seabornInstance.set_context("paper", rc={"axes.labelsize":20})
seabornInstance.set_context("talk", font_scale=1.4)
xpl=seabornInstance.pairplot(mtcars, kind='reg', diag_kind='hist',height=7, aspect=1)