Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
488 views
in Technique[技术] by (71.8m points)

python - Speed up swarmplot/stripplot in seaborn > 0.9.0?

After an update to seaborn 0.11.1 from 0.9.0 I noticed that swarmplot and stripplot became MUCH slower when adding a hue variable.

I am plotting ~4000 data points across ~100 categories and 3 hue levels.

In seaborn 0.9.0 this was much faster and took ~5 seconds. Now it takes 30-60 seconds.

Without adding a hue variable, the speed is comparable between the versions.

I determined this changed with the update to 0.9.1 by trying various versions of seaborn. Is there a new setting that I missed that I can use to recapitulate the old performance in newer versions of seaborn?

question from:https://stackoverflow.com/questions/65916968/speed-up-swarmplot-stripplot-in-seaborn-0-9-0

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

My guess about what caused this is the change in 0.9.1 to match vectors based on pandas index information rather than position, which I think happened in a for-loop over the hues within each category and therefore probably didn't scale well to many categories. I don't know how you would avoid it in 0.11.1 but the good news is that those functions have been rewritten since then and a simple example with the dimensionality that you describe runs quickly (~1 s) now.

Without seeing an example of exactly what you're trying to do it's a little hard to advise, but my guess would be that in most situations with 100 categories you can't really see the jitter/swarming, so you should be able to get away with using scatterplot...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...