-
Notifications
You must be signed in to change notification settings - Fork 2
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
Tex use #36
Conversation
I guess this depend on the latex distribution that the user has installed? Using tinytex, I run into four missing packages: (with texlive-full i guess it will just work?) Input
import matplotlib.pyplot as plt
import cosmoplots
plt.style.use(["cosmoplots.default"])
import numpy as np
a = np.exp(np.linspace(-3, 1, 100))
# Plotting
fig = plt.figure()
ax1 = plt.gca()
ax1.set_xlabel("X Axis")
ax1.set_ylabel("Y Axis")
base = 2 # Default is 10, but 2 works equally well
# Do plotting ...
ax1.semilogx(a)
# It is recommended to call the change_log_axis_base function after doing all the
# plotting. By default, it will try to infer the scaling used for the axis and only
# adjust accordingly.
cosmoplots.change_log_axis_base(ax1, base=base)
# Plotting
fig = plt.figure()
ax2 = plt.gca()
ax2.set_xlabel("X Axis")
ax2.set_ylabel("Y Axis")
base = 2 # Default is 10, but 2 works equally well
cosmoplots.change_log_axis_base(ax2, "x", base=base)
# Do plotting ...
# If you use "plot", the change_log_axis_base can be called at the top (along with add_axes
# etc.), but using loglog, semilogx, semilogy will re-set, and the change_log_axis_base
# function must be called again.
ax2.plot(a)
plt.savefig("test.png") # also jpg, pdf Issues# issue 1
! LaTeX Error: File `type1cm.sty' not found.
$ tlmgr install type1cm
# issue 2
! LaTeX Error: File `type1ec.sty' not found.
$ tlmgr install cm-super
# issue 3
! LaTeX Error: File `underscore.sty' not found.
$ tlmgr install underscore
# issue 4
...
RuntimeError: Failed to process string with tex because dvipng could not be found
$ tlmgr install dvipng Successful run |
Yes, we should probably say it needs TeX-Live. I'll check if this is true. Does tinytex ship with any fonts? What is the default? |
@engeir Try with Latin Modern instead. |
@audunth There is no difference for me whether I use the Latin Modern or serif+cm commits, same four packages need to be installed if tinytex is used. Just tested with texlive-full, in which case it works out-of-the-box, no |
As I expect most (of our) users to have some form of texlive (I had not heard of tinytex before), I think a mention in the Readme is good enough. On Computer Modern vs Latin Modern, it seems there are reasons to prefer Latin Modern: matplotlib/matplotlib#28172 If none of us have problems with Tex Live + Latin Modern, we stick to that. |
We have confirmed it works out of the box on mac as well. |
LaTeX is an implicit dependency for cosmoplots. Here, we make the dependency explicit in the Readme.
Also, since Computer Modern is the default LaTeX font, we change to this - anyone with a working LaTeX installation should have access to this font, unlike 'Times' (which is not by default available on Fedora / Arch).