Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Noninteger Bases in mathtext sqrt #8665

Copy link
Copy link
Closed
@ben-e-whitney

Description

@ben-e-whitney
Issue body actions

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.