r4ds-python-plotnine
r4ds-python-plotnine copied to clipboard
TeX Improvements
Thank you for creating this extensive tutorial. A few improvements on using TeX:
- All you need to do is wrap the text with
$
. - You can avoid the double escaping by using raw strings i.e
r'string'
.
So this chunk
from matplotlib import rc
rc('text', usetex=True)
df = pd.DataFrame({"x": np.random.uniform(size=10),
"y": np.random.uniform(size=10)})
ggplot(df, aes("x", "y")) +\
geom_point() +\
labs(x="$\\sum_{i = 1}^n{x_i^2}$",
y="$\\alpha + \\beta + \\frac{\\delta}{\\theta}$")
becomes this
df = pd.DataFrame({"x": np.random.uniform(size=10),
"y": np.random.uniform(size=10)})
ggplot(df, aes("x", "y")) +\
geom_point() +\
labs(x=r"$\sum_{i = 1}^n{x_i^2}$",
y=r"$\alpha + \beta + \frac{\delta}{\theta}$")