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 plt
fig = plt.figure()
axis = fig.add_subplot(1, 1, 1)
axis.plot(1, 1, label=r'$\sqrt[a]{{x}}$')
axis.legend()
plt.show()
Actual outcome
mathtext.Parser.parse
raises a ValueError
.
Expected outcome
The documentation 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. From mathtext.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 the python3.5
package in the stretch
repository and Matplotlib from the python3-matplotlib
package in the stretch
repository, but I'm not sure.