garrettj403 / SciencePlots

Matplotlib styles for scientific plotting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Times New Roman: Bad looking plus/minus sign.

leo-hstone opened this issue · comments

image

The plus and minus signs are somehow shifted downwards. It would be awesome if anyone could reproduce this and/or knows how to fix it!

Hi!
I haven't found a right way of solving that, but two notes:

  • See this StackOverflow thread about the minus sign.
  • See this matplotlib docs about Latex and changing the font
    For the latter, you'll make use of rcParams. See following code:
import matplotlib.pyplot as plt
import matplotlib
import pandas as pd

data = pd.DataFrame(zip([0, 2, 4],[1, 3, 5]), columns=[r'+0',r'-8'])

plt.style.use(['science'])
plt.rcParams['axes.unicode_minus'] = False
plt.rcParams['font.family'] = 'Courier'  # This is a monospace font. See more at https://matplotlib.org/stable/tutorials/text/usetex.html

data.plot()
plt.show()

Hope to have helped!!!