gpt4 book ai didi

python - 如何更改 seaborn tsplot 的大小?

转载 作者:行者123 更新时间:2023-11-28 22:41:52 25 4
gpt4 key购买 nike

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 并不是绝对必要的,但可能是好的形式。

关于python - 如何更改 seaborn tsplot 的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32246778/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com