The width
parameter works fine for a single sided arrow but I get an error when using a double sided arrow.
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 10, 1000)
plt.plot(x, np.sin(x));
plt.annotate('', xy=(3.2, 0), xycoords='data',
xytext=(5.9, 0), textcoords='data',
arrowprops=dict(facecolor='black', width=3))
This works fine and results in this plot:
The code also works for a double sided arrow with no width specified:
plt.annotate('', xy=(3.2, 0), xycoords='data',
xytext=(5.9, 0), textcoords='data',
arrowprops=dict(facecolor='black', arrowstyle='<->'))
But for a double arrow with width:
plt.annotate('', xy=(3.2, 0), xycoords='data',
xytext=(5.9, 0), textcoords='data',
arrowprops=dict(facecolor='black', width=3, arrowstyle='<->'))
results in the matplotlib error: "AttributeError: Unknown property width"
Try this:
arrowprops=dict(facecolor='black', lw=3, arrowstyle='<->')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With