Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using arrowstyle causes "Unknown property shrink" #3697

Closed
wikiped opened this issue Oct 22, 2014 · 3 comments
Closed

Using arrowstyle causes "Unknown property shrink" #3697

wikiped opened this issue Oct 22, 2014 · 3 comments
Milestone

Comments

@wikiped
Copy link

wikiped commented Oct 22, 2014

Using one of the examples from the gallery where in arrowprops= arrowstyle='simple' has been added:

fig = figure()
ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1,5), ylim=(-3,5))

t = np.arange(0.0, 5.0, 0.01)
s = np.cos(2*np.pi*t)
line, = ax.plot(t, s, lw=3, color='purple')

ax.annotate('offset', xy=(1, 1),  xycoords='data',
            xytext=(-15, 10), textcoords='offset points',
            arrowprops=dict(arrowstyle='simple', facecolor='black', shrink=0.05),
            horizontalalignment='right', verticalalignment='bottom')

Results in:

AttributeError: Unknown property shrink

Removing shrink attribute produces chart as expected.

@tacaswell tacaswell added this to the v1.4.2 milestone Oct 22, 2014
@pganssle
Copy link
Member

I am inferring from the code here that this is in annotation_demo.py, but I am unable to replicate this bug in version 1.3.0 or 1.4.2. @wikiped Is it possible you are using an old version from before "shrink" was implemented?

@wikiped
Copy link
Author

wikiped commented Dec 22, 2014

@pganssle Sorry, I should have mentioned this, but you are right this example was extracted from annotation_demo.py. And unfortunately I still get the same error message. Just deleting shrink=x.xx "solves" the error.

And I am using latest version:

matplotlib.__version__
1.4.2

matplotlib.__version__numpy__
1.6 

Error details:

D:\Anaconda\envs\py2k\lib\site-packages\matplotlib\artist.pyc in update(self, props)
    755             func = getattr(self, 'set_' + k, None)
    756             if func is None or not six.callable(func):
--> 757                 raise AttributeError('Unknown property %s' % k)
    758             func(v)
    759             changed = True
AttributeError: Unknown property shrink

Python 2.7.9 (anaconda distribution) on Win8.1 x64 if it matters.

@tacaswell
Copy link
Member

Ah, the problem is that if you use the simple arrow style which, it turns out, completely changes the code path that is taken. If 'arrowstyle' is in the dictionary then the arrowprops dictionary is used to create a FancyArrow patch. If arrowstyle is not in arrowprops than the dictionary is used to create a YAArrow object.

This is documented, along with the valid kwargs, in http://matplotlib.org/api/text_api.html#matplotlib.text.Annotation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants