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

Path effects applied to annotation text containing \n #4024

Closed
dkirkby opened this issue Jan 21, 2015 · 4 comments · Fixed by #5217
Closed

Path effects applied to annotation text containing \n #4024

dkirkby opened this issue Jan 21, 2015 · 4 comments · Fixed by #5217

Comments

@dkirkby
Copy link

dkirkby commented Jan 21, 2015

I am using the following test program with mathplotlib 1.4.0 (via anaconda) on OS X 10.10.1:

import matplotlib.pyplot as plt
import matplotlib.patheffects as pe

plt.subplot(1,1,1)
plt.annotate('line1\nline2',xy=(0.5,0.5),xycoords='axes fraction',fontsize='x-large',
    path_effects=[pe.withStroke(linewidth=1,foreground='r')])
plt.show()

This fails with:

AttributeError: GraphicsContextBase instance has no attribute 'draw_path'

Removing the \n from the text or removing the path_effects option both run as expected. Any workarounds you can suggest are appreciated.

@tacaswell tacaswell added this to the v1.5.x milestone Jan 22, 2015
@cimarronm
Copy link
Contributor

Definitely a problem with the MacOS backend and probably affects other backends which use a stack-based graphics context

@cimarronm
Copy link
Contributor

@dkirkby This should be resolved with PR #4201 and #4202.

The workaround without these fixes applied is to separate out the annotation into separate annotations (without the newline).

@tacaswell tacaswell modified the milestones: next point release, proposed next point release May 15, 2015
tacaswell added a commit to tacaswell/matplotlib that referenced this issue Jun 19, 2015
Was falling back to the base implementation of get_rgb which looks at a
local variable which was getting out of sync with the stack.  Now
consults the underlying cairo context.

Closes matplotlib#4024 for cairo based backends
@jenshnielsen
Copy link
Member

I don't think this is fixed for OSX so I will reopen #4542 fixed it for Cairo which caused this to auto close

@jenshnielsen jenshnielsen reopened this Aug 6, 2015
@tacaswell tacaswell modified the milestones: proposed next point release, next point release Aug 9, 2015
@tacaswell
Copy link
Member

not blocking 1.5 on this unless @mdehoon wants to.

mdboom added a commit to mdboom/matplotlib that referenced this issue Oct 9, 2015
The special sub-GC that is created by the PathEffectRenderer was of
GraphicsContextBase, rather than the backend-specific GC.

Fix matplotlib#5049, Fix matplotlib#4024
@mdboom mdboom assigned mdboom and unassigned cimarronm Oct 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment