如何更改 seaborn tsplot 的大小?
How do I change the size of a seaborn tsplot?
Seaborn's tsplot
不像其他绘图类型(例如 lmplot
)那样提供 size
选项。我知道这是因为 tsplot
是轴级函数,而 lmplot
是图形级函数。
问题:
我真的只是想要一个简单的 tsplot
并像我在 lmplot
中那样设置图形的大小。我该怎么做?
我试过的:
这可能意味着我必须将 FacetGrid
(只有一个方面)与我的 tsplot
结合起来。网上似乎没有任何直接的例子。
当我这样做时:
sns.tsplot(data = data, time = "index", value = "score", unit = "mode", condition = "mode")
我得到了一个不错的情节,条件颜色正确,只是尺寸错误:
grid = sns.FacetGrid(data, size = 10)
grid.map(sns.tsplot, data = data, time = "index", value = "score", unit = "mode", condition = "mode")
我明白了:
tsplot
只是绘制到当前活动的 matplotlib 轴上,除非您为 ax
参数指定一个。这意味着在 matplotlib 中控制图形大小的各种方法中的任何一种都适用。我的首选方法是:
f, ax = plt.subplots(figsize=(10, 4))
sns.tsplot(..., ax=ax)
在这里指定 ax
并不是绝对必要的,但可能是好的形式。
Seaborn's tsplot
不像其他绘图类型(例如 lmplot
)那样提供 size
选项。我知道这是因为 tsplot
是轴级函数,而 lmplot
是图形级函数。
问题:
我真的只是想要一个简单的 tsplot
并像我在 lmplot
中那样设置图形的大小。我该怎么做?
我试过的:
这可能意味着我必须将 FacetGrid
(只有一个方面)与我的 tsplot
结合起来。网上似乎没有任何直接的例子。
当我这样做时:
sns.tsplot(data = data, time = "index", value = "score", unit = "mode", condition = "mode")
我得到了一个不错的情节,条件颜色正确,只是尺寸错误:
grid = sns.FacetGrid(data, size = 10)
grid.map(sns.tsplot, data = data, time = "index", value = "score", unit = "mode", condition = "mode")
我明白了:
tsplot
只是绘制到当前活动的 matplotlib 轴上,除非您为 ax
参数指定一个。这意味着在 matplotlib 中控制图形大小的各种方法中的任何一种都适用。我的首选方法是:
f, ax = plt.subplots(figsize=(10, 4))
sns.tsplot(..., ax=ax)
在这里指定 ax
并不是绝对必要的,但可能是好的形式。