简体   繁体   中英

How do I change the size of a seaborn tsplot?

Seaborn's tsplot does not offer a size option like some of the other plot types (eg, lmplot ). I understand that this is due to tsplot being an axis-level function and lmplot , for example, being a figure-level function.

Question:

I really just want a simple tsplot and set the size of the figure like I would do in lmplot . How can I do that?

What I've tried:

This probably means I have to combine a FacetGrid (with just one facet) with my tsplot . There does not seem to be any straightforward example online.

When I do:

sns.tsplot(data = data, time = "index", value = "score", unit = "mode", condition = "mode")

I get a nice plot, with the condition properly colored, just with the wrong size:

grid = sns.FacetGrid(data, size = 10)
grid.map(sns.tsplot, data = data, time = "index", value = "score", unit = "mode", condition = "mode")

I get this:

tsplot just plots onto the currently active matplotlib axes, unless you specify one to the ax parameter. That means any of the various ways to control the figure size in matplotlib apply. My preferred approach would be:

f, ax = plt.subplots(figsize=(10, 4))
sns.tsplot(..., ax=ax)

It's not strictly necessary to specify the ax here, but probably good form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM