如何使用seaborn factorplot更改图形大小 [英] How to change figuresize using seaborn factorplot

查看:139
本文介绍了如何使用seaborn factorplot更改图形大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

%pylab inline

import pandas as pd
import numpy as np
import matplotlib as mpl
import seaborn as sns

typessns = pd.DataFrame.from_csv('C:/data/testesns.csv', index_col=False, sep=';')

mpl.rc("figure", figsize=(45, 10))
sns.factorplot("MONTH", "VALUE", hue="REGION", data=typessns, kind="box", palette="OrRd");

我总是得到一个小尺寸的数字,无论我在 figsize 中指定什么尺寸...如何解决?

I always get a small size figure, no matter what size I 've specified in figsize... How to fix it?

推荐答案

2019 年添加的注释:在现代 seaborn 版本中,size 参数已重命名为 height.

更具体一点:

%matplotlib inline

import seaborn as sns

exercise = sns.load_dataset("exercise")

# Defaults are size=5, aspect=1
sns.factorplot("kind", "pulse", "diet", exercise, kind="point", size=2, aspect=1)
sns.factorplot("kind", "pulse", "diet", exercise, kind="point", size=4, aspect=1)
sns.factorplot("kind", "pulse", "diet", exercise, kind="point", size=4, aspect=2)

您想在构建绘图时将参数size"或aspect"传递给 sns.factorplot().

You want to pass in the arguments 'size' or 'aspect' to the sns.factorplot() when constructing your plot.

尺寸会改变高度,同时保持纵横比(所以如果只改变尺寸,它也会变宽.)

Size will change the height, while maintaining the aspect ratio (so it will also also get wider if only size is changed.)

Aspect 将改变宽度,同时保持高度不变.

Aspect will change the width while keeping the height constant.

上面的代码应该可以在 ipython notebook 本地运行.

The above code should be able to be run locally in an ipython notebook.

在这些示例中缩小了绘图大小以显示效果,并且因为上述代码中的绘图在保存为 png 时相当大.这也表明 size/aspect 包括边距中的图例.

大小=2,方面=1

大小=4,方面=1

大小=4,方面=2

此外,一旦加载sns"模块,就可以查看此绘图函数的所有其他有用参数/参数和默认值:

Also, all other useful parameters/arguments and defaults for this plotting function can be viewed with once the 'sns' module is loaded:

help(sns.factorplot)

这篇关于如何使用seaborn factorplot更改图形大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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