Use theme font also for LaTeX

Abierto
#942 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
matplotlib, python

Línea de trabajo

Comienza con el ejemplo reproducible de plotnine e inspecciona cómo se aplican las fuentes de texto del theme junto con la configuración de LaTeX y mathtext de matplotlib. Rastrea el manejo de las fuentes del theme y determina la configuración relevante de matplotlib; el trabajo estará terminado cuando las labels renderizadas en LaTeX utilicen la font family especificada por el theme sin requerir rcParams globales separados.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Apparently, matplotlib uses different rcParams for controlling the font used in LaTeX environments vs outside (see https://stackoverflow.com/a/27697390). This causes behaviour which is IMO inconsistent, where the font family specified in the theme is not used within LaTeX environments.

Reproducible example to show what I mean:

from plotnine import ggplot, geom_point, aes, theme, labs, element_text
from plotnine.data import penguins

(ggplot(penguins, aes(x="bill_length_mm", y="bill_depth_mm")) 
 + labs(x="l_bill", y=r"$d_\text{bill}$")
 + theme(text = element_text(family="Noto Serif"), figure_size=(3,2))
 + geom_point()
)

yields this:

Image

where the LaTeX in the y axis label does not use the serif font which I specified in the theme

Prepending this:

import matplotlib
matplotlib.rcParams['mathtext.fontset'] = 'custom'
matplotlib.rcParams['mathtext.rm'] = 'Noto Serif'
matplotlib.rcParams['mathtext.it'] = 'Noto Serif:italic'

achieves the desired result in this case, but of course, the theme information is no longer stored in the theme.

Is it possible to change the behaviour such that the LaTeX font follows the theme font?

Lenguaje dominante
Python
Estrellas
4.8k
Forks
260
Merge medio
2 d 12 h
PR fusionados (30 d)
4

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de has2k1/plotnine

Todos los issues de has2k1/plotnine

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.