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

查看:244
本文介绍了如何使用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.

Note added in 2019: In modern seaborn versions the size argument has been renamed to 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 will change the width while keeping the height constant.

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

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

在这些示例中减小了图的大小以显示效果,并且因为上述代码中的图在另存为png时相当大.这也表明大小/方面在图例中包括图例.

尺寸= 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天全站免登陆