adjustText
adjustText copied to clipboard
The text is not aligning properly with the arrows
Hi,
I am trying your library but the text is not aligning properly with the arrows. The code I have written is as follows:
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1) #top and bottom left
texts = [plt.text(p1_0[i], p2_0[i], idx_0[i]) for i in range(len(p1_0))]
adjust_text(texts,
# only_move={'points':'', 'text':'y', 'objects':'y'}, force_text=0.75, force_objects=0.1,
arrowprops=dict(arrowstyle='->', color='blue'))
ax.scatter(p1_0,p2_0,marker = 'o',label = "Bit flip X")
texts = [plt.text(p1_1[i], p2_1[i], idx_1[i]) for i in range(len(p1_1))]
adjust_text(texts,
# only_move={'points':'', 'text':'y', 'objects':'y'}, force_text=0.75, force_objects=0.1,
arrowprops=dict(arrowstyle='->', color='yellow'))
ax.scatter(p1_1,p2_1,marker = 's', label = "Bit flip Y")
texts = [plt.text(p1_2[i], p2_2[i], idx_2[i]) for i in range(len(p1_2))]
adjust_text(texts,
# only_move={'points':'', 'text':'y', 'objects':'y'}, force_text=0.75, force_objects=0.1,
arrowprops=dict(arrowstyle='->', color='green'))
ax.scatter(p1_2,p2_2,marker = 'd', label = "Hadamard X")
texts = [plt.text(p1_3[i], p2_3[i], idx_3[i]) for i in range(len(p1_3))]
adjust_text(texts,
# only_move={'points':'', 'text':'y', 'objects':'y'}, force_text=0.75, force_objects=0.1,
arrowprops=dict(arrowstyle='->', color='red'))
ax.scatter(p1_3,p2_3,marker = 'x', label = "Hadamard Y")
texts = [plt.text(p1_4[i], p2_4[i], idx_4[i]) for i in range(len(p1_4))]
adjust_text(texts,
# only_move={'points':'', 'text':'y', 'objects':'y'}, force_text=0.75, force_objects=0.1,
arrowprops=dict(arrowstyle='->', color='purple'))
ax.scatter(p1_4,p2_4,marker = '+', label = "measurement")
texts = [plt.text(p1_5[i], p2_5[i], idx_5[i]) for i in range(len(p1_5))]
adjust_text(texts,
# only_move={'points':'', 'text':'y', 'objects':'y'}, force_text=0.75, force_objects=0.1,
arrowprops=dict(arrowstyle='->', color='brown'))
ax.scatter(p1_5,p2_5,marker = '^', label = "nothing")
I end up getting an image like this
Can you help me?
Hi, can you please make a minimal reproducible example?
What do you mean?
Some code I can copy and run directly that shows the issue.
Sorry, I'm answering from my phone, maybe I'm missing something here.
Oh, okay. That's fine. Answer when you have access to a machine. But please let me know what's the issue. Why is the text not aligning properly?
Some code I could run would help, here you don't include the actual values you used - and it can be much shorter.
Here's are some values. You can assign the parameters these values and you'll get the graph:
https://gist.github.com/Flock1/2af3652a8cea1fb0f8ac69e2501538b0
I can't reproduce your issue. Using your values and your code I get this:
Which versions of adjustText and matplotlib do you have?
Note that in general you should call adjust_text
once per plot with all the texts, it won't repel objects used in different calls. And to avoid texts with the same coordinates from sticking together, you can add a tiny value to the coordinates, so that they start getting repelled.
Hi
matplotlib: 2.2.3 adjusttext: 0.7.3.1
What do you suggest?
Can you try upgrading matplotlib?
On Fri, Dec 27, 2019, 08:22 Flock-Anizak [email protected] wrote:
Hi
matplotlib: 2.2.3 adjusttext: 0.7.3.1
What do you suggest?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Phlya/adjustText/issues/88?email_source=notifications&email_token=AAWCZOQHQT53DXOJULJ7PXDQ2WNKPA5CNFSM4J66WCL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHWU2UA#issuecomment-569199952, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWCZOVHMKT6CFQCGF5P2EDQ2WNKPANCNFSM4J66WCLQ .
which version?
Something above 3 at least, can you just get the latest?
On Fri, Dec 27, 2019, 16:51 Flock-Anizak [email protected] wrote:
which version?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Phlya/adjustText/issues/88?email_source=notifications&email_token=AAWCZOXZTPVWCZ2JJZ2XMTDQ2YI77A5CNFSM4J66WCL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHXJRLA#issuecomment-569284780, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWCZOQN4QYTMHBALJAY2ZTQ2YI77ANCNFSM4J66WCLQ .
I'll try that
I had the same problem, and it got better with autoalign=False