Coder Social home page Coder Social logo

Comments (6)

Phlya avatar Phlya commented on August 19, 2024 1

@zealseeker Yes, it's actually quite powerful, because you can specify any "restricted" region on the plot, but does require some fiddling with the parameters sometimes.
That's weird, I think this shouldn't happen, because both of them should restrict movement to only along the y axis... I'll look into it when I have time. Also if you don't mind I'd like to add your example to my example notebook, I think this is probably quite a common use case.

I also hope it becomes popular, thank you!

from adjusttext.

Phlya avatar Phlya commented on August 19, 2024

Hi zealseeker, thanks for trying it. My guess is that this has to do with different size of the subplot (because that's the only thing that is different really and it can influence overlaps between labels). However if you want to avoid labels moving down, you have to add virtual points below the top of your bars, otherwise there is nothing preventing them from doing it. Let me know if it helps!

from adjusttext.

zealseeker avatar zealseeker commented on August 19, 2024

@Phlya unfortunately, even substantial points cannot fix this problem (I have updated the notebook in my repository) . Is it possible and necessary to restrict the moving direction besides axis. For example only_move={'text':'y+'} means that the label can only move upward ?

from adjusttext.

Phlya avatar Phlya commented on August 19, 2024

@zealseeker I think you misunderstood what I meant.

First, a comment: you want to have your labels above bars and at their centers. So it's best to specify this when adding texts (texts.append(ax.text(left,top,'%.3f'%y[j], horizontalalignment='center'))). (I actually don't understand why you get centered labels if you don't do it...)

And about adding points. You don't need to plot any additional points, but rather supply the adjust_text function with virtual points in the x and y parameters. I modified your notebook and created a PR for you to have a look.

I have been thinking about adding this functionality, but haven't found the time to implement it yet.

from adjusttext.

Phlya avatar Phlya commented on August 19, 2024

(Oh, actually you use the left side of bars as the x coordinate to add texts...)

from adjusttext.

zealseeker avatar zealseeker commented on August 19, 2024

@Phlya Thank you. It's a good way to temporarily solve the problem. But acturally I found that horizontalalignment='center' is not necessary. The labels get centered due to autoalign='y'. Both of autoalign='y', only_move={'points':'y', 'text':'y'} are indispensable, or else the labels would run away.
Anyhow, thank you very much and hope the module will be updated and become popular.

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.