Phlya / adjustText

A small library for automatically adjustment of text position in matplotlib plots to minimize overlaps.
https://adjusttext.readthedocs.io/
MIT License
1.5k stars 87 forks source link

adjustText seems very slow with python3 #104

Open apiddington opened 4 years ago

apiddington commented 4 years ago

Hi, I have adjustText 0.6.1 installed using python2 on ubuntu 18.04. Running it with some 60 labels the response is almost instantaneous. Version 0.7.3 on a virtual machine running python3 on ubuntu 20.04 the same plot takes 20.5 secs. On the same machine and v0.6.3 it is 3.9 secs. Version 0.8b2 is a similar time to 0.7.3. I'm wondering why there is such a large increase in run time. Regards

Phlya commented 4 years ago

Strange. Are the results actually the same everywhere?

apiddington commented 4 years ago

I'm not sure what you mean by the 'same everywhere', but there is certainly a 5 fold time difference between v0.6.3 and v0.7.3 in exactly the same environment. I suppose I should do some more testing. I will try python2 on the virtual machine and compare.

Phlya commented 4 years ago

I mean the actual plots, do they look the same? Is it the same number of steps required?

apiddington commented 4 years ago

I hadn't looked carefully, but no they are all a bit different. That is v0.6.1 with python2, v0.6.1 with python3, v0.6.3 python3, and v0.7.3 and python3. Not very different and all quite acceptable.

apiddington commented 4 years ago

I have tried with python2, python3 with adjustText 0.6.1 and 0.7.3 on the same virtual environment on Ubuntu 18.04, and while there is a little increase in runtime it's not very significant. I'll see what happens when I update my desktop to Ubuntu 20.04.

I wasn't able to install all the required python2 modules on Ubuntu 20.04. Hence my upgrade to python3.

Hopefully it won't be the 20secs from the virtual environment.

Thanks for the response. FYI here are my timings:

Python version: 2.7.17, adjustText version: 0.6.1, matplotlib version: 2.2.5 adjustText time: 2.9 secs adjustText time: 1.3 secs adjustText time: 0.0 secs Total adjustText time: 4.2 secs

Python version: 3.6.9, adjustText version: 0.6.1, matplotlib version: 3.3.1 adjustText time: 3.5 secs adjustText time: 1.4 secs adjustText time: 0.1 secs Total adjustText time: 4.9 secs

Python version: 2.7.17, adjustText version: 0.7.3, matplotlib version: 2.2.5 adjustText time: 1.9 secs adjustText time: 3.1 secs adjustText time: 0.1 secs Total adjustText time: 5.1 secs

Python version: 3.6.9, adjustText version: 0.7.3, matplotlib version: 3.3.1 adjustText time: 2.7 secs adjustText time: 3.5 secs adjustText time: 0.1 secs Total adjustText time: 6.2 secs

Phlya commented 4 years ago

So basically the difference is not that dramatic after all?

I wouldn't bother with python2, it's basically not supported.