--- name: add_header_logo kind: function lang: py domain: infra version: "1.0.0" purity: impure signature: "add_header_logo(fig: Figure, image: np.ndarray, x: float = 0.88, y: float = 0.905, width: float = 0.08, height: float = 0.08) -> None" description: "Añade un logo como axes inset en la esquina superior derecha de una figura matplotlib. Usa fig.add_axes + imshow + axis off. Útil para branding en páginas de informe PDF." tags: [pdf, matplotlib, logo, report, infra] uses_functions: [] uses_types: [] returns: [] returns_optional: false error_type: "error_go_core" imports: [matplotlib] params: - name: fig desc: "Figura matplotlib donde se inserta el logo." - name: image desc: "Array numpy H×W×C con los datos de imagen del logo (e.g. de imread o PIL)." - name: x desc: "Borde izquierdo del axes en coordenadas de figura (0-1). Default 0.88." - name: y desc: "Borde inferior del axes en coordenadas de figura (0-1). Default 0.905." - name: width desc: "Ancho del axes en coordenadas de figura (0-1). Default 0.08." - name: height desc: "Alto del axes en coordenadas de figura (0-1). Default 0.08." output: "None. Modifica la figura in-place añadiendo un axes con el logo." tested: true tests: - "figura nueva con imagen zeros no lanza excepcion" - "axes de logo tiene axis off" test_file_path: "python/functions/infra/tests/test_add_header_logo.py" file_path: "python/functions/infra/add_header_logo.py" source_repo: "internal:footprint_aurgi" source_license: "internal-aurgi" source_file: "ponderacion_isochronas/src/recomendador_centros.py" --- ## Ejemplo ```python import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt import numpy as np logo = np.zeros((50, 200, 3), dtype=np.uint8) # o matplotlib.image.imread("logo.png") fig, ax = plt.subplots(figsize=(11.69, 8.27)) add_header_logo(fig, logo) ``` ## Notas La posición por defecto (x=0.88, y=0.905) coloca el logo en la esquina superior derecha para figuras A4 landscape. Ajustar x, y, width, height para otros tamaños.