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

mathtext mishandling of certain exponents #5864

Closed
anntzer opened this issue Jan 17, 2016 · 8 comments · Fixed by #5880
Closed

mathtext mishandling of certain exponents #5864

anntzer opened this issue Jan 17, 2016 · 8 comments · Fixed by #5880
Assignees
Milestone

Comments

@anntzer
Copy link
Contributor

anntzer commented Jan 17, 2016

From the second example for twin axes in AxesGrid1, where the intent was probably to have a "seconds of angle" symbol:

$ python
Python 3.5.1 (default, Dec  7 2015, 12:58:09) 
[GCC 5.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt; plt.gca().set_xlabel("$^{''}$/yr"); plt.show()
<matplotlib.text.Text object at 0x7f6451604f98>

(same result from within ipython with %matplotlib active)
screenshot_20160116_211600

EDIT: This part is invalid and should be ignored
Weirdly enough, running the same command from with python -c a different result:

$ python -c 'import matplotlib.pyplot as plt; plt.gca().set_xlabel("$^{''}$/yr"); plt.show()'

screenshot_20160116_211836

(checked without any matplotlibrc).

Preempting @tacaswell to @zblz this time :-)

@tacaswell tacaswell added this to the next major release (2.0) milestone Jan 17, 2016
@QuLogic
Copy link
Member

QuLogic commented Jan 17, 2016

The result with python -c is different because the single quotes in the middle end and start two Bash strings.

@anntzer
Copy link
Contributor Author

anntzer commented Jan 17, 2016

Oops, failed at triple nesting my quotes. The main issue still stands though.

@anntzer anntzer changed the title Strange mathtext behavior (for lack of better description...) mathtext mishandling of certain exponents Jan 17, 2016
@zblz
Copy link
Member

zblz commented Jan 17, 2016

The first result is definitely weird, I have no idea where that phi comes from. I'll take a look to try to find the culprit.

For the record, the proper way of of typesetting arcseconds would be with primes $^{\prime\prime}$.

@zblz
Copy link
Member

zblz commented Jan 17, 2016

Also note that this only happens with the Computer Modern mathtext fontset (which is default in 1.5.x but will not be in 2.x). with the dejavusans fontset the rendering is better but there is still some weirdness with the first ':
2016-01-17-122456_1366x768_scrot

anntzer added a commit to anntzer/matplotlib that referenced this issue Jan 17, 2016
@zblz
Copy link
Member

zblz commented Jan 17, 2016

So I narrowed the behaviour down to two effects:

  • mathtext will convert apostrophes into ^\prime, so that's why the second apostrophe gets typeset correctly, but it will only do this change to apostrophes coming after a nucleus (so it will change $a'$ into $a^{\prime}$ but not $'$ into $^\prime$). Because of this, {}'' would actually give the correct behaviour.
  • the latex_to_bakoma dictionary does not have an entry for ', and the Bakoma fonts included do not have a quotesingle character, only quoteleft and quoteright. I don't know why the lack of a entry results in \phi, though.

The second part could be fixed by adding an entry in the latex_to_bakoma dict to, e.g., quoteleft. However, I think fixing the behaviour of the first part (converting all ' to superscripted primes) is better. I am still having some trouble implementing that, though.

@efiring
Copy link
Member

efiring commented Jan 17, 2016

On 2016/01/17 10:40 AM, Victor Zabalza wrote:

However, I think fixing the behaviour of the first part (converting all
|'| to superscripted primes) is better.

If I understand correctly, this is making mathtext less compatible
with LaTeX. Is this a desired result? Granted, $^\prime$ is clunky
and ugly.

@anntzer
Copy link
Contributor Author

anntzer commented Jan 17, 2016

Actually I just learnt that ' is an active character in tex that gets converted to ^\prime (plus some more). So it's actually more compatible.

anntzer added a commit to anntzer/matplotlib that referenced this issue Jan 18, 2016
- Proper typing of "prime" in docs, see matplotlib#5864.
- Update broken link.
zblz added a commit to zblz/matplotlib that referenced this issue Jan 19, 2016
@zblz
Copy link
Member

zblz commented Jan 19, 2016

@anntzer - I did not know about ' being an active character (hence my comment above about a proper way...), it looks very useful. I tried to add the full functionality of that in #5880 so that even apostrophes as first charachters get recognised as primes.

anntzer added a commit to anntzer/matplotlib that referenced this issue Jan 19, 2016
- Proper typing of "prime" in docs, see matplotlib#5864.
- Update broken link.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants