dhaitz/mplcyberpunk

Not compatible with LaTeX mode.

eduardo-vitral opened this issue · 2 comments

Dear dhaitz,

Congratulations for the package, it's very nice!

However, it doesn't seem to be compatible with LaTeX mode. For example, when doing:

import matplotlib.pyplot as plt
import mplcyberpunk

from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
rc('text', usetex=True)

plt.style.use("cyberpunk")

plt.plot([1, 3, 9, 5, 2, 1, 1], marker='o')
plt.plot([4, 5, 5, 7, 9, 8, 6], marker='o')
plt.title(r'$\mathrm{test}$')

mplcyberpunk.add_glow_effects()

plt.show()

The code crashes. It would be nice to update it for scientific uses :)

cheers,
Eduardo

Hey @eduardo-vitral ,

thanks for reporting this! What error do you get? Does it work without mplcyberpunk?

When I execute your code snippet (on MacOS, not sure my TeX is up to date), I get

CalledProcessError
....
RuntimeError: latex was not able to process the following string:
b'lp'

However, simply by setting usetex=False instead of True, it works:
Bildschirmfoto 2020-09-23 um 18 22 58

Note sure if this is related to daft-dev/daft#65 (comment)

Cheers,
Dominik

[edit: typo]

I get the same error then the following:

https://stackoverflow.com/questions/11354149/python-unable-to-render-tex-in-matplotlib

I guess it was due to conflicting installations when I did "pip install mplcyberpunk". It might be nice to check if it overwrites some necessary packages for LaTeX.

I managed to correct it in a similar way then proposed in the link above, but I uninstalled mplcyberpunk to be sure I could still plot some other plots from my work.

When using uselatex=False, the code works indeed, but I would suggest you to look into that so people using LaTeX can have Figures and texts with the same font :)

thanks for the quick reply,
cheers,
Eduardo