Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug report
Bug summary
It appears that only integer sqrt bases are allowed by mathtext. The documentation does not list this limitation.
Code for reproduction
import matplotlib.pyplot as pltfig = plt.figure()axis = fig.add_subplot(1, 1, 1)axis.plot(1, 1, label=r'$\sqrt[a]{{x}}$')axis.legend()plt.show()
Actual outcomemathtext.Parser.parse
raises aValueError
.
Expected outcome
Thedocumentation states the following:
Radicals can be produced with the \sqrt[]{} command ... Any base can (optionally) be provided inside square brackets. Note that the base must be a simple expression, and can not contain layout commands such as fractions or sub/superscripts
In fact, it seems that only a (signed) integer literal is allowed. Frommathtext.Parser.__init__
:
p.sqrt <<= Group( Suppress(Literal(r"\sqrt")) - ((Optional(p.lbracket + p.int_literal + p.rbracket, default=None) + p.required_group) | Error("Expected \sqrt{value}")) )
It would be convenient if other bases were allowed. If that change cannot be made (or in the meantime), I think the documentation should be updated.
Matplotlib version
- Operating System: Debian 9.0
- Matplotlib Version: 2.0.0
- Python Version: 3.5.3
I believe I installed Python from thepython3.5
package in thestretch
repository and Matplotlib from thepython3-matplotlib
package in thestretch
repository, but I'm not sure.