adjustText
adjustText copied to clipboard
Get final text coordinates
Hi, good package! Can I get the text coordinates? So I can reuse the coordinate data to plot texts using other packages (not Matplotlib)? Or, can I use the package without the support of Matplotib? Thank you.
import matplotlib.pyplot as plt
from adjustText import adjust_text
import numpy as np
import pandas as pd
np.random.seed(0)
x, y = np.random.random((2,30))
fig, ax = plt.subplots()
plt.plot(x, y, 'bo')
texts = [plt.text(x[i], y[i], 'Text%s' %i) for i in range(len(x))]
print(texts)
adjust_text(texts)
print(texts)
you will find two different result , and the final one is what you want.
While the actual issue is solved with above, I'm curious about the possibility adjustText could be used in other packages @starfriend10 could you clarify your usecase? With the new engine it will be very simple to move just the logic into a separate function that could be used for any similar situation.