adjustText icon indicating copy to clipboard operation
adjustText copied to clipboard

Get final text coordinates

Open starfriend10 opened this issue 4 years ago • 2 comments

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.

starfriend10 avatar Feb 06 '21 15:02 starfriend10

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.

witwall avatar Dec 06 '21 03:12 witwall

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.

Phlya avatar Feb 27 '23 13:02 Phlya