Coder Social home page Coder Social logo

Comments (6)

Phlya avatar Phlya commented on August 19, 2024

Would you be able to share some example data?

from adjusttext.

Phlya avatar Phlya commented on August 19, 2024

Also - are you using the latest version?

from adjusttext.

ThomasParistech avatar ThomasParistech commented on August 19, 2024

I'm using adjustText==1.1.1

Here's a minimal reproducible example (with JSON data)

import json
import matplotlib.pyplot as plt
from adjustText import adjust_text

path = "data/test.json"

with open(path, encoding="utf-8") as f:
    data = json.load(f)
    curve_x = data["curve_x"]
    curve_y = data["curve_y"]
    list_x = data["list_x"]
    list_y = data["list_y"]
    list_text = data["list_text"]

plt.plot(curve_x, curve_y, color="r", lw=2)
plt.plot(list_x, list_y, '^', color="g", markersize=10)


texts = [plt.text(x, y, txt, ha='center', va='center', fontsize=8)
         for x, y, txt in zip(list_x, list_y, list_text)]


adjust_text(texts,
            x=curve_x,
            y=curve_y,
            time_lim=2,
            arrowprops=dict(arrowstyle='->', color='red'))


plt.axis('equal')
plt.gca().invert_yaxis()

plt.show()

image

test.json

from adjusttext.

ThomasParistech avatar ThomasParistech commented on August 19, 2024

I got roughly the same result when removing plt.axis('equal') and plt.gca().invert_yaxis()
image

from adjusttext.

Phlya avatar Phlya commented on August 19, 2024

When there are so many points it's a bit tricky. Here is some arguments in the right direction, you can experiment a bit more.

adjust_text(texts, x=curve_x, y=curve_y, force_explode=0, force_static=(2e-3, 5e-3),
            time_lim=2, expand=(1, 1),
            arrowprops=dict(arrowstyle="->", color='r', lw=0.5))

image

from adjusttext.

ThomasParistech avatar ThomasParistech commented on August 19, 2024

Thanks for the parameter suggestion!
But it turns out that textalloc works better in this specific scenario (ckjellson/textalloc#18), I'll use it instead
cheers :)

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.