Opened 11 years ago

Closed 9 years ago

#8125 closed defect (worksforme)

problem with "text" in matplotlib

Reported by: jhpalmieri Owned by: was
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: graphics Keywords: matplotlib
Cc: Merged in:
Authors: Reviewers: John Palmieri
Report Upstream: Fixed upstream, in a later stable release. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

In Sage 4.3.2.alpha0:

sage: text(r"$\left(2 a=b\right)$", (2,3))   # works fine 
sage: text(r"$(2 \, a=b)$", (2,3))   # works fine 
sage: text(r"$\left(2 \, a=b\right)$", (2,3))   # error! 
Traceback (click to the left of this block for traceback) 
... 
AttributeError: 'Kern' object has no attribute 'height' 

Change History (9)

comment:1 Changed 11 years ago by jhpalmieri

  • Report Upstream changed from N/A to Not yet reported upstream; Will do shortly.

This seems to be a bug in matplotlib; I just reported it to the matplotlib-devel mailing list, and I'll report any answers I get.

Meanwhile, this arises in "real life" as follows:

sage: var("y R") 
sage: a(y,R) = pi * (2*R - y) * y 
sage: latex(a(y,R))
{\left(2 \, R - y\right)} \pi y

Therefore

sage: lbl = text(r"$\int \  " + latex(a(y,R)) + "$",(3,20)) 

won't work with matplotlib. Should we get rid of the "\," in the latex output?

comment:2 Changed 11 years ago by kcrisman

Any response?

comment:3 Changed 11 years ago by jhpalmieri

No response at all. From python:

>>> import pylab
>>> pylab.text(0.2, 0.2, r"$\left(2a = b\right)$")
<matplotlib.text.Text object at 0x1020aa450>
>>> pylab.savefig('a.png')
>>> pylab.text(0.2, 0.2, r"$(2a \, = b)$")
<matplotlib.text.Text object at 0x101e22a50>
>>> pylab.savefig('b.png')
>>> pylab.text(0.2, 0.2, r"$\left(2a \, = b\right)$")
<matplotlib.text.Text object at 0x1020b5750>
>>> pylab.savefig('c.png')
BOOM

Combining \left(, \right)}]}, and {{{\, seems to lead to problems. So now what? Do we get rid of the \,?

comment:4 Changed 10 years ago by jhpalmieri

  • Keywords matplotlib added
  • Summary changed from problem with "text" to problem with "text" in matplotlib

This is still an issue in Sage 4.6.alpha3: it has not been fixed in matplotlib 1.0.0.

comment:5 Changed 10 years ago by mdboom

  • Resolution set to fixed
  • Status changed from new to closed

Fixed by this pull request in matplotlib:

https://github.com/matplotlib/matplotlib/pull/52

This will make it into the next matplotlib bugfix release.

comment:6 Changed 10 years ago by mhansen

  • Report Upstream changed from Not yet reported upstream; Will do shortly. to Fixed upstream, in a later stable release.
  • Resolution fixed deleted
  • Status changed from closed to new

We keep tickets open until the fix has actually gone into a Sage release.

comment:7 Changed 9 years ago by jhpalmieri

  • Milestone changed from sage-5.0 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

This works now; it must be in matplotlib 1.1.0 (or earlier). So this ticket can be closed.

comment:8 Changed 9 years ago by jhpalmieri

  • Status changed from needs_review to positive_review

comment:9 Changed 9 years ago by jdemeyer

  • Resolution set to worksforme
  • Reviewers set to John Palmieri
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.