Coder Social home page Coder Social logo

Comments (14)

Phlya avatar Phlya commented on September 28, 2024 4

As I mentioned above, you have to add ax=ax to adjust_text call:

fig, axes = plt.subplots(1, 2, figsize=(8, 3), sharex=True, sharey=True)
axes = axes.ravel()

for k, ax in enumerate(axes):
    np.random.seed(0)
    x, y = np.random.random((2,30))
    ax.plot(x, y, 'bo')

    texts = []
    for i in range(len(x)):
        t = ax.text(x[i], y[i], 'Text%s' %i, ha='center', va='center')
        texts.append(t)
    adjust_text(texts, ax=ax)

image

from adjusttext.

Phlya avatar Phlya commented on September 28, 2024

from adjusttext.

zyxue avatar zyxue commented on September 28, 2024

Thanks, I will try it out. BTW, will ax.set_xlim or ax.set_ylim have an effect on adjustText? I saw some strange behavior before.

from adjusttext.

Phlya avatar Phlya commented on September 28, 2024

from adjusttext.

Phlya avatar Phlya commented on September 28, 2024

@zyxue did this solve your problems?

from adjusttext.

zyxue avatar zyxue commented on September 28, 2024

@Phlya, thank you for asking, but no, it's not working yet. I am trying to get a minimal reproducible example

from adjusttext.

zyxue avatar zyxue commented on September 28, 2024

I've made an example at https://github.com/zyxue/adjustText/blob/master/figures/Examples-for-multiple-subplots.ipynb.

Also, it seems to be much slower than in a single-subplot case (17.9 ms vs 13.4 s).

from adjusttext.

zyxue avatar zyxue commented on September 28, 2024

Ah I see. I didn't fully get that. Ok, I will try it out later and let you know. Thank you!

from adjusttext.

Phlya avatar Phlya commented on September 28, 2024

Concerning timing, make sure you are using axes of the same size/shape, when comparing single vs multiple subplots. If they are slightly smaller in one case, it can slow down the execution considerably.

from adjusttext.

zyxue avatar zyxue commented on September 28, 2024

I don't fully understand what you mean by "If they are slightly smaller in one case, it can slow down the execution considerably".

I have updated my notebooks, why the time spent is so different for adjusting the first and second subplots, please?

CPU times: user 11.7 s, sys: 236 ms, total: 12 s
Wall time: 12 s
CPU times: user 2.52 s, sys: 57.8 ms, total: 2.57 s
Wall time: 2.58 s

BTW, are you interested in a pull request, I thought having a such an example for multiple subplots would be helpful to other users. It's a very useful package, thank you for sharing it.

from adjusttext.

Phlya avatar Phlya commented on September 28, 2024

Oh, I see. Interesting, I don't know why that is so different, for some reason it does a very different number of iterations each time! I'll try to investigate when I have time...
screenshot from 2018-07-23 00-51-49

from adjusttext.

Phlya avatar Phlya commented on September 28, 2024

Yeah, would be great to add an example about this, you are not the first person to ask this question!

from adjusttext.

zyxue avatar zyxue commented on September 28, 2024

ok, I've sent a pull request. Not I also removed figures/.ipynb_checkpoints from the commit as it's in your .gitignore already.

from adjusttext.

zyxue avatar zyxue commented on September 28, 2024

Reopen because the time discrepancy for different subplots hasn't been resolsoved

Quote a previous comment:

CPU times: user 11.7 s, sys: 236 ms, total: 12 s
Wall time: 12 s
CPU times: user 2.52 s, sys: 57.8 ms, total: 2.57 s
Wall time: 2.58 s

from adjusttext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.