garrettj403 / SciencePlots

Matplotlib styles for scientific plotting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Greater symbol is not displayed correctly.

davidzanger opened this issue · comments

Environment

System: Windows-10-10.0.19045-SP0
Python: 3.11.6 | packaged by conda-forge | (main, Oct  3 2023, 10:29:11) [MSC v.1935 64 bit (AMD64)]
SciencePlots: 2.1.1
Matplotlib: 3.8.0
LaTeX distro: This is pdfTeX, Version 3.141592653-2.6-1.40.25 (MiKTeX 23.5) (preloaded format=latex.fmt)
 restricted \write18 enabled.

Affected styles

["science"]

Describe the issue here

When trying to display the greater symbol in the legend, it is not displayed correctly.

How can we replicate it? What have you tried? Please, add a reproducible example

Here is a minimal example:

    import scienceplots
    import matplotlib.pyplot as plt
    plt.style.use('science')
    plt.plot(1, 2, label='>test')
    plt.legend()
    plt.show()

Output is:
grafik

Extra info

No response

Yeah, that's because you are using latex and supporting those glyphs depends on encoding/font.

https://tex.stackexchange.com/questions/2369/why-do-the-less-than-symbol-and-the-greater-than-symbol-appear-wrong-as

The following code works, with the latex commands instead. Note it is enclosed in a raw string.

import scienceplots
import matplotlib.pyplot as plt
plt.style.use('science')
plt.plot(1, 2, label=r'>test \textgreater \textless')
plt.legend()
plt.show()