tesorotools-python 0.1.13__tar.gz → 0.1.15__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/PKG-INFO +1 -1
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/__init__.py +3 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/__init__.py +2 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/names.py +3 -1
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/plotly_backend.py +28 -0
- tesorotools_python-0.1.15/src/tesorotools/artists/treemap.py +379 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/assets/plots.yaml +14 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/note/builder.py +18 -6
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/note/lint.py +146 -10
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/note/skeleton.md +20 -6
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/note/skill/SKILL.md +56 -14
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/note/skill/reglas.md +44 -9
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/palette.py +2 -1
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/builder.py +10 -2
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/charts.py +13 -15
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/house.py +3 -1
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/native.py +42 -22
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/.gitignore +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/pyproject.toml +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/_build_context.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/_registry.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/_bars.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/_common.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/_dates.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/bar_line.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/barh_plot.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/box_plot.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/compact.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/intraday_plot.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/line_plot.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/matrix.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/review.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/sankey.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/scatter.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/sharing.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/shock_plot.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/stacked.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/tikz_backend.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/type_curve.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/vector_plot.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/waterfall.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/assets/README.md +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/assets/fonts/CabinetGrotesk-Black.otf +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/assets/fonts/CabinetGrotesk-Bold.otf +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/assets/fonts/CabinetGrotesk-Extrabold.otf +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/assets/fonts/CabinetGrotesk-Extralight.otf +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/assets/fonts/CabinetGrotesk-Light.otf +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/assets/fonts/CabinetGrotesk-Medium.otf +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/assets/fonts/CabinetGrotesk-Regular.otf +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/assets/fonts/CabinetGrotesk-Thin.otf +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/assets/fonts/README.md +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/assets/nota_template.dotx +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/assets/template.docx +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/assets/tesoro.mplstyle +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/data_sources/__init__.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/data_sources/debug.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/database/__init__.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/database/local.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/database/push.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/database/shared.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/dates.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/dependencies/__init__.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/dependencies/node.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/dependencies/resolution.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/driver.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/extend.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/__init__.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/cli.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/scaffold.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/article/main.tex.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/article/sections/01-introduccion.tex +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/article/sections/02-analisis.tex +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/article/sections/03-conclusiones.tex +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/beamer/main.tex.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/beamer/slides/01-contexto.tex +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/beamer/slides/02-analisis.tex +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/beamer/slides/03-conclusiones.tex +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/beamer/style/beamerthemeTesoro.sty +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/book/appendices/a-fuentes.tex +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/book/chapters/01-introduccion.tex +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/book/chapters/02-analisis.tex +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/book/frontmatter/resumen.tex +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/book/main.tex.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/common/README.md.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/common/dot-gitignore +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/common/dot-vscode/settings.json +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/common/figures/dot-gitkeep +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/common/fonts/README.md +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/common/latexmkrc +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/common/refs.bib +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/common/style/tesoro.sty +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/common/style/tesorobrand.sty.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/latex/templates/common/style/tesorolocal.sty.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/manifest.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/note/__init__.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/note/charts.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/note/cli.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/note/inline.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/note/issues.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/note/markdown.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/note/pdf.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/note/template.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/offsets/__init__.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/offsets/offsets.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/offsets/outliers.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/orchestration.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/pipeline/__init__.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/pipeline/diagnose.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/pipeline/engine.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/pipeline/rules.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/__init__.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/cli.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/fit.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/fonts.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/glossary.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/lint.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/markdown.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/pdf.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/sections.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/skeleton.md +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/skill/SKILL.md +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/skill/reglas.md +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/presentation/template.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/providers/__init__.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/providers/base.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/providers/bde.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/providers/ecb.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/providers/fred.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/providers/imf_irfcl.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/providers/lseg.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/py.typed +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/render/__init__.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/render/content/__init__.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/render/content/content.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/render/content/images.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/render/content/section.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/render/content/subtitle.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/render/content/table.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/render/content/text.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/render/content/title.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/render/document.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/render/report.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/scaffold.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/testing/__init__.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/testing/compare.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/utils/__init__.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/utils/config.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/utils/format.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/utils/globals.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/utils/matplotlib.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/utils/series.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/utils/shortcuts.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/utils/template.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/__init__.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/app.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/brand.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/cli.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/components.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/formatting.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/launcher.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/palette.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/period.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/plotting.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/scaffold.py +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/templates/Dockerfile.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/templates/README.md.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/templates/dot-dockerignore.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/templates/dot-gitignore.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/templates/dot-streamlit/config.toml.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/templates/pyproject.toml.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/templates/src/$package/__init__.py.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/templates/src/$package/cli.py.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/templates/src/$package/main.py.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/templates/src/$package/sections.py.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/templates/tests/__init__.py.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/templates/tests/test_app.py.tmpl +0 -0
- {tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/web/theme.py +0 -0
|
@@ -79,6 +79,7 @@ from tesorotools.artists import (
|
|
|
79
79
|
ShockChart,
|
|
80
80
|
StackedAreaPlot,
|
|
81
81
|
StackedBarPlot,
|
|
82
|
+
TreemapChart,
|
|
82
83
|
TypeCurve,
|
|
83
84
|
VectorPlot,
|
|
84
85
|
Waterfall,
|
|
@@ -134,6 +135,7 @@ def _register_builtins() -> None:
|
|
|
134
135
|
register_artist("waterfall", Waterfall)
|
|
135
136
|
register_artist("sankey", SankeyPlot)
|
|
136
137
|
register_artist("scatter", ScatterPlot)
|
|
138
|
+
register_artist("treemap", TreemapChart)
|
|
137
139
|
|
|
138
140
|
register_tag("format", Format)
|
|
139
141
|
register_tag("legend", Legend)
|
|
@@ -191,6 +193,7 @@ __all__ = [
|
|
|
191
193
|
"TemplateLoader",
|
|
192
194
|
"Text",
|
|
193
195
|
"Title",
|
|
196
|
+
"TreemapChart",
|
|
194
197
|
"TypeCurve",
|
|
195
198
|
"VectorPlot",
|
|
196
199
|
"Waterfall",
|
|
@@ -66,6 +66,7 @@ from tesorotools.artists.sharing import (
|
|
|
66
66
|
)
|
|
67
67
|
from tesorotools.artists.shock_plot import ShockChart
|
|
68
68
|
from tesorotools.artists.stacked import StackedAreaPlot, StackedBarPlot
|
|
69
|
+
from tesorotools.artists.treemap import TreemapChart
|
|
69
70
|
from tesorotools.artists.type_curve import TypeCurve
|
|
70
71
|
from tesorotools.artists.vector_plot import VectorPlot
|
|
71
72
|
from tesorotools.artists.waterfall import Waterfall
|
|
@@ -90,6 +91,7 @@ __all__ = [
|
|
|
90
91
|
"ShockChart",
|
|
91
92
|
"StackedAreaPlot",
|
|
92
93
|
"StackedBarPlot",
|
|
94
|
+
"TreemapChart",
|
|
93
95
|
"TypeCurve",
|
|
94
96
|
"VectorPlot",
|
|
95
97
|
"Waterfall",
|
|
@@ -68,9 +68,11 @@ KIND_NAMES: dict[str, KindName] = {
|
|
|
68
68
|
"type_curve": KindName(("curva", "curva_de_tipos", "curva_tipos")),
|
|
69
69
|
"vector_plot": KindName(("vectores", "flechas")),
|
|
70
70
|
"matrix": KindName(("matriz", "mapa_de_calor")),
|
|
71
|
-
|
|
71
|
+
# known by its English name too: «sankey» is the one printed
|
|
72
|
+
"sankey": KindName(("sankey", "diagrama_de_flujos", "flujos")),
|
|
72
73
|
"shock_plot": KindName(("impactos", "choques", "perturbaciones")),
|
|
73
74
|
"intraday": KindName(("intradia",)),
|
|
75
|
+
"treemap": KindName(("treemap", "mapa_de_arbol", "mapa_de_rectangulos")),
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
|
{tesorotools_python-0.1.13 → tesorotools_python-0.1.15}/src/tesorotools/artists/plotly_backend.py
RENAMED
|
@@ -70,6 +70,7 @@ if TYPE_CHECKING:
|
|
|
70
70
|
from tesorotools.artists.scatter import ScatterPlot
|
|
71
71
|
from tesorotools.artists.shock_plot import ShockChart
|
|
72
72
|
from tesorotools.artists.stacked import StackedAreaPlot, StackedBarPlot
|
|
73
|
+
from tesorotools.artists.treemap import TreemapChart
|
|
73
74
|
from tesorotools.artists.type_curve import TypeCurve
|
|
74
75
|
from tesorotools.artists.vector_plot import VectorPlot
|
|
75
76
|
from tesorotools.artists.waterfall import Waterfall
|
|
@@ -87,6 +88,7 @@ __all__ = [
|
|
|
87
88
|
"shock_chart_to_figure",
|
|
88
89
|
"stacked_area_to_figure",
|
|
89
90
|
"stacked_bar_to_figure",
|
|
91
|
+
"treemap_to_figure",
|
|
90
92
|
"type_curve_to_figure",
|
|
91
93
|
"vector_plot_to_figure",
|
|
92
94
|
"waterfall_to_figure",
|
|
@@ -1258,6 +1260,32 @@ def sankey_to_figure(chart: SankeyPlot) -> go.Figure:
|
|
|
1258
1260
|
return fig
|
|
1259
1261
|
|
|
1260
1262
|
|
|
1263
|
+
def treemap_to_figure(chart: TreemapChart) -> go.Figure:
|
|
1264
|
+
"""Interactive ``Figure`` from a :class:`TreemapChart` (``go.Treemap``).
|
|
1265
|
+
|
|
1266
|
+
The same parts in the same colours, each labelled with its name and
|
|
1267
|
+
the figure (and share) of the PNG; Plotly lays the rectangles out on
|
|
1268
|
+
its own, with the same squarified algorithm.
|
|
1269
|
+
"""
|
|
1270
|
+
tiles = chart.tiles()
|
|
1271
|
+
fig = _new_figure()
|
|
1272
|
+
fig.add_trace(
|
|
1273
|
+
go.Treemap(
|
|
1274
|
+
ids=[t.id for t in tiles],
|
|
1275
|
+
labels=[t.label for t in tiles],
|
|
1276
|
+
parents=[""] * len(tiles),
|
|
1277
|
+
values=[t.value for t in tiles],
|
|
1278
|
+
customdata=[chart.figure_text(t) for t in tiles],
|
|
1279
|
+
texttemplate="<b>%{label}</b><br>%{customdata}",
|
|
1280
|
+
hovertemplate="%{label}: %{customdata}<extra></extra>",
|
|
1281
|
+
marker={"colors": [t.color for t in tiles]},
|
|
1282
|
+
sort=False,
|
|
1283
|
+
tiling={"packing": "squarify", "pad": 2},
|
|
1284
|
+
)
|
|
1285
|
+
)
|
|
1286
|
+
return fig
|
|
1287
|
+
|
|
1288
|
+
|
|
1261
1289
|
#: ``ScatterPlot`` label side -> Plotly ``textposition``.
|
|
1262
1290
|
_TEXT_POSITION = {
|
|
1263
1291
|
"above right": "top right",
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
"""Treemap: the parts of a total as rectangles, each as big as its share.
|
|
2
|
+
|
|
3
|
+
Defines :class:`TreemapChart`, the YAML-tag-aware artist registered as
|
|
4
|
+
``!treemap``. Input is the shape :class:`HorizontalBarChart` reads: a
|
|
5
|
+
``pd.DataFrame`` indexed by id with the figure in ``value_column``, and
|
|
6
|
+
``series`` choosing and naming the parts (all the rows when omitted).
|
|
7
|
+
Typical use: who holds the debt, what the budget is spent on, the
|
|
8
|
+
weight of each country in an index.
|
|
9
|
+
|
|
10
|
+
The rectangles are laid out with the *squarified* algorithm (Bruls,
|
|
11
|
+
Huizing and van Wijk, 2000) in the real proportions of the figure, so
|
|
12
|
+
they come out as close to squares as the figures allow, the largest at
|
|
13
|
+
the top left. Each one is filled in a ramp of the house blue (the
|
|
14
|
+
largest the darkest) unless ``colors`` says otherwise, and carries its
|
|
15
|
+
name, its figure and its share of the total when they fit; a part too
|
|
16
|
+
small to hold its name stays unlabelled.
|
|
17
|
+
|
|
18
|
+
Styling constants come from ``PLOT_CONFIG['treemap']``.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
from collections.abc import Sequence
|
|
24
|
+
from dataclasses import dataclass
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
from typing import Any, ClassVar, Self
|
|
27
|
+
|
|
28
|
+
import matplotlib.pyplot as plt
|
|
29
|
+
import pandas as pd
|
|
30
|
+
from matplotlib.axes import Axes
|
|
31
|
+
from matplotlib.colors import to_hex, to_rgba
|
|
32
|
+
from matplotlib.figure import Figure
|
|
33
|
+
from matplotlib.patches import Rectangle
|
|
34
|
+
from matplotlib.text import Text
|
|
35
|
+
from yaml.nodes import MappingNode
|
|
36
|
+
|
|
37
|
+
from tesorotools import palette
|
|
38
|
+
from tesorotools.artists._common import (
|
|
39
|
+
FigureLifecycle,
|
|
40
|
+
Format,
|
|
41
|
+
compact_figure_kwargs,
|
|
42
|
+
compact_font_pt,
|
|
43
|
+
resolve_data,
|
|
44
|
+
)
|
|
45
|
+
from tesorotools.utils.matplotlib import PLOT_CONFIG, chart_number
|
|
46
|
+
from tesorotools.utils.template import TemplateLoader
|
|
47
|
+
|
|
48
|
+
__all__ = ["TreemapChart", "squarify"]
|
|
49
|
+
|
|
50
|
+
TREEMAP_CONFIG: dict[str, Any] = PLOT_CONFIG.get("treemap", {})
|
|
51
|
+
|
|
52
|
+
Rect = tuple[float, float, float, float]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dataclass(frozen=True)
|
|
56
|
+
class Tile:
|
|
57
|
+
"""One part of the treemap: its id, label, figure, share of the total
|
|
58
|
+
(0-1), colour and rectangle ``(x, y, width, height)``, ``y`` growing
|
|
59
|
+
downwards from the top."""
|
|
60
|
+
|
|
61
|
+
id: str
|
|
62
|
+
label: str
|
|
63
|
+
value: float
|
|
64
|
+
share: float
|
|
65
|
+
color: str
|
|
66
|
+
rect: Rect
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _worst(row: Sequence[float], side: float) -> float:
|
|
70
|
+
"""The worst aspect ratio of the areas *row* laid along *side*."""
|
|
71
|
+
total = sum(row)
|
|
72
|
+
return max(
|
|
73
|
+
max(
|
|
74
|
+
side * side * a / (total * total), total * total / (side * side * a)
|
|
75
|
+
)
|
|
76
|
+
for a in row
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def squarify(
|
|
81
|
+
values: Sequence[float], width: float, height: float
|
|
82
|
+
) -> list[Rect]:
|
|
83
|
+
"""The rectangles of *values* (positive, largest first) in a
|
|
84
|
+
*width* x *height* box, each with the area of its share.
|
|
85
|
+
|
|
86
|
+
Rectangles are ``(x, y, width, height)`` with ``y`` growing
|
|
87
|
+
downwards: the first value sits at the top left. Each strip is laid
|
|
88
|
+
along the shorter side of what is left, and takes values while that
|
|
89
|
+
keeps its worst aspect ratio from getting worse.
|
|
90
|
+
"""
|
|
91
|
+
scale = width * height / sum(values)
|
|
92
|
+
areas = [v * scale for v in values]
|
|
93
|
+
x, y, w, h = 0.0, 0.0, float(width), float(height)
|
|
94
|
+
rects: list[Rect] = []
|
|
95
|
+
i = 0
|
|
96
|
+
while i < len(areas):
|
|
97
|
+
side = min(w, h)
|
|
98
|
+
row = [areas[i]]
|
|
99
|
+
i += 1
|
|
100
|
+
while i < len(areas) and _worst([*row, areas[i]], side) <= _worst(
|
|
101
|
+
row, side
|
|
102
|
+
):
|
|
103
|
+
row.append(areas[i])
|
|
104
|
+
i += 1
|
|
105
|
+
strip = sum(row)
|
|
106
|
+
if w >= h: # a column on the left, top to bottom
|
|
107
|
+
across = strip / h
|
|
108
|
+
top = y
|
|
109
|
+
for a in row:
|
|
110
|
+
rects.append((x, top, across, a / across))
|
|
111
|
+
top += a / across
|
|
112
|
+
x, w = x + across, w - across
|
|
113
|
+
else: # a row on top, left to right
|
|
114
|
+
across = strip / w
|
|
115
|
+
left = x
|
|
116
|
+
for a in row:
|
|
117
|
+
rects.append((left, y, a / across, across))
|
|
118
|
+
left += a / across
|
|
119
|
+
y, h = y + across, h - across
|
|
120
|
+
return rects
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def _ramp(n: int) -> list[str]:
|
|
124
|
+
"""*n* colours from the dark to the light end of the house ramp."""
|
|
125
|
+
dark = to_rgba(TREEMAP_CONFIG.get("dark", f"#{palette.BLUE}"))
|
|
126
|
+
light = to_rgba(TREEMAP_CONFIG.get("light", f"#{palette.BLUE_PALE}"))
|
|
127
|
+
steps = max(n - 1, 1)
|
|
128
|
+
|
|
129
|
+
def mix(k: int) -> tuple[float, float, float, float]:
|
|
130
|
+
r, g, b, a = (d + (lt - d) * k / steps for d, lt in zip(dark, light))
|
|
131
|
+
return (r, g, b, a)
|
|
132
|
+
|
|
133
|
+
return [to_hex(mix(k)) for k in range(n)]
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def _text_color(fill: str) -> str:
|
|
137
|
+
"""White on a dark fill, the dark text on a light one."""
|
|
138
|
+
r, g, b, _ = to_rgba(fill)
|
|
139
|
+
luminance = 0.299 * r + 0.587 * g + 0.114 * b
|
|
140
|
+
if luminance < float(TREEMAP_CONFIG.get("luminance_threshold", 0.55)):
|
|
141
|
+
return str(TREEMAP_CONFIG.get("light_text", "white"))
|
|
142
|
+
return str(TREEMAP_CONFIG.get("dark_text", "#1a1a1a"))
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class TreemapChart(FigureLifecycle):
|
|
146
|
+
"""Treemap of the parts of a total.
|
|
147
|
+
|
|
148
|
+
Parameters
|
|
149
|
+
----------
|
|
150
|
+
out_path
|
|
151
|
+
``.png`` path the rendered chart is saved to.
|
|
152
|
+
data, data_path
|
|
153
|
+
Provide one. A DataFrame indexed by the ids of the parts with
|
|
154
|
+
their figure in ``value_column``.
|
|
155
|
+
series
|
|
156
|
+
``id -> label`` of the parts to draw; all the rows of ``data``,
|
|
157
|
+
by their id, when omitted. The order does not matter: the
|
|
158
|
+
parts are drawn from the largest.
|
|
159
|
+
value_column
|
|
160
|
+
Column of ``data`` with the figures (default ``value``); they
|
|
161
|
+
must be positive.
|
|
162
|
+
colors
|
|
163
|
+
``id -> colour`` (``"C0"``..., names or hex) of the parts that
|
|
164
|
+
do not take the blue ramp.
|
|
165
|
+
fmt
|
|
166
|
+
Number format of the figures.
|
|
167
|
+
show_share
|
|
168
|
+
Add the share of the total to each label (``45,2 (38 %)``).
|
|
169
|
+
Default ``True``.
|
|
170
|
+
figsize, compact, font_pt
|
|
171
|
+
As in the other artists. ``compact`` renders at the fixed
|
|
172
|
+
compact size with ``compact.font_pt`` text (or ``font_pt``).
|
|
173
|
+
"""
|
|
174
|
+
|
|
175
|
+
#: Keys that change the PNG but never the ``to_plotly()`` figure
|
|
176
|
+
#: (see :func:`plotly_unsupported`); checked against real renders
|
|
177
|
+
#: by ``tests/test_plotly_support.py``.
|
|
178
|
+
PLOTLY_UNSUPPORTED: ClassVar[frozenset[str]] = frozenset(
|
|
179
|
+
{
|
|
180
|
+
"compact",
|
|
181
|
+
"figsize",
|
|
182
|
+
"font_pt",
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
def __init__(
|
|
187
|
+
self,
|
|
188
|
+
out_path: Path,
|
|
189
|
+
*,
|
|
190
|
+
data: pd.DataFrame | None = None,
|
|
191
|
+
data_path: Path | None = None,
|
|
192
|
+
series: dict[str, str] | None = None,
|
|
193
|
+
value_column: str = "value",
|
|
194
|
+
colors: dict[str, str] | None = None,
|
|
195
|
+
fmt: Format | None = None,
|
|
196
|
+
show_share: bool = True,
|
|
197
|
+
figsize: tuple[float, float] | None = None,
|
|
198
|
+
compact: bool = False,
|
|
199
|
+
font_pt: float | None = None,
|
|
200
|
+
) -> None:
|
|
201
|
+
if out_path.suffix != ".png":
|
|
202
|
+
raise ValueError(f"out_path must be .png: {out_path}")
|
|
203
|
+
self.out_path = out_path
|
|
204
|
+
self.data = resolve_data(data, data_path)
|
|
205
|
+
#: Feather the data came from (None: built from in-memory data);
|
|
206
|
+
#: kept so the chart can be written back to YAML.
|
|
207
|
+
self.data_path = data_path
|
|
208
|
+
self.series = series
|
|
209
|
+
self.value_column = value_column
|
|
210
|
+
self.colors = colors or {}
|
|
211
|
+
self.fmt = fmt or Format(decimals=1)
|
|
212
|
+
self.show_share = show_share
|
|
213
|
+
self.figsize = figsize
|
|
214
|
+
self.compact = compact
|
|
215
|
+
self.font_pt = font_pt
|
|
216
|
+
|
|
217
|
+
@classmethod
|
|
218
|
+
def from_yaml(cls, loader: TemplateLoader, node: MappingNode) -> Self:
|
|
219
|
+
"""Build a :class:`TreemapChart` from the ``!treemap`` YAML tag.
|
|
220
|
+
|
|
221
|
+
Required keys: ``out_path`` and ``data_path`` (``.feather``).
|
|
222
|
+
Every other ``__init__`` keyword is forwarded.
|
|
223
|
+
|
|
224
|
+
Example
|
|
225
|
+
-------
|
|
226
|
+
.. code-block:: yaml
|
|
227
|
+
|
|
228
|
+
tenedores: !treemap
|
|
229
|
+
out_path: out/tenedores.png
|
|
230
|
+
data_path: data/tenedores.feather
|
|
231
|
+
series: {bancos: Bancos, fondos: Fondos, bce: Eurosistema}
|
|
232
|
+
fmt: !format {decimals: 1, units: " mm"}
|
|
233
|
+
"""
|
|
234
|
+
cfg: dict[str, Any] = loader.construct_mapping( # type: ignore[assignment]
|
|
235
|
+
node, deep=True
|
|
236
|
+
)
|
|
237
|
+
cfg.pop("id", None)
|
|
238
|
+
cfg["out_path"] = Path(cfg["out_path"])
|
|
239
|
+
if "data_path" in cfg:
|
|
240
|
+
cfg["data_path"] = Path(cfg["data_path"])
|
|
241
|
+
return cls(**cfg)
|
|
242
|
+
|
|
243
|
+
# ------------------------------------------------------------------
|
|
244
|
+
# Backend-neutral layout
|
|
245
|
+
# ------------------------------------------------------------------
|
|
246
|
+
|
|
247
|
+
def parts(self) -> list[tuple[str, str, float]]:
|
|
248
|
+
"""``(id, label, value)`` of each part, the largest first."""
|
|
249
|
+
if self.value_column not in self.data.columns:
|
|
250
|
+
raise KeyError(
|
|
251
|
+
f"TreemapChart value_column {self.value_column!r} not in data"
|
|
252
|
+
)
|
|
253
|
+
series = self.series or {str(i): str(i) for i in self.data.index}
|
|
254
|
+
index = {str(i): i for i in self.data.index}
|
|
255
|
+
missing = [s for s in series if s not in index]
|
|
256
|
+
if missing:
|
|
257
|
+
raise KeyError(f"TreemapChart ids not found in data: {missing}")
|
|
258
|
+
values = self.data[self.value_column]
|
|
259
|
+
parts = [
|
|
260
|
+
(s, label, float(values[index[s]])) for s, label in series.items()
|
|
261
|
+
]
|
|
262
|
+
bad = [label for _, label, v in parts if not v > 0]
|
|
263
|
+
if bad:
|
|
264
|
+
raise ValueError(f"a treemap draws positive figures only: {bad}")
|
|
265
|
+
return sorted(parts, key=lambda p: -p[2])
|
|
266
|
+
|
|
267
|
+
def tiles(self, width: float = 1.0, height: float = 1.0) -> list[Tile]:
|
|
268
|
+
"""The parts laid out in a *width* x *height* box."""
|
|
269
|
+
parts = self.parts()
|
|
270
|
+
total = sum(v for _, _, v in parts)
|
|
271
|
+
ramp = _ramp(len(parts))
|
|
272
|
+
rects = squarify([v for _, _, v in parts], width, height)
|
|
273
|
+
return [
|
|
274
|
+
Tile(
|
|
275
|
+
s,
|
|
276
|
+
label,
|
|
277
|
+
v,
|
|
278
|
+
v / total,
|
|
279
|
+
to_hex(self.colors[s]) if s in self.colors else ramp[n],
|
|
280
|
+
rect,
|
|
281
|
+
)
|
|
282
|
+
for n, ((s, label, v), rect) in enumerate(
|
|
283
|
+
zip(parts, rects, strict=True)
|
|
284
|
+
)
|
|
285
|
+
]
|
|
286
|
+
|
|
287
|
+
def figure_text(self, tile: Tile) -> str:
|
|
288
|
+
"""The figure of *tile*, and its share when ``show_share``."""
|
|
289
|
+
text = chart_number(tile.value, self.fmt.decimals, self.fmt.units)
|
|
290
|
+
if not self.show_share:
|
|
291
|
+
return text
|
|
292
|
+
decimals = int(TREEMAP_CONFIG.get("share_decimals", 0))
|
|
293
|
+
share = chart_number(100 * tile.share, decimals, " %")
|
|
294
|
+
return f"{text} ({share})"
|
|
295
|
+
|
|
296
|
+
# ------------------------------------------------------------------
|
|
297
|
+
# Renderers
|
|
298
|
+
# ------------------------------------------------------------------
|
|
299
|
+
|
|
300
|
+
def to_plotly(self) -> Any:
|
|
301
|
+
"""Render the same treemap as an interactive Plotly figure.
|
|
302
|
+
|
|
303
|
+
Requires the optional ``interactive_plots`` extra (``plotly``),
|
|
304
|
+
imported lazily.
|
|
305
|
+
"""
|
|
306
|
+
from tesorotools.artists.plotly_backend import treemap_to_figure
|
|
307
|
+
|
|
308
|
+
return treemap_to_figure(self)
|
|
309
|
+
|
|
310
|
+
def build(self) -> tuple[Figure, Axes]:
|
|
311
|
+
"""Render the treemap in memory and return ``(Figure, Axes)``."""
|
|
312
|
+
fig: Figure = plt.figure( # type: ignore[reportUnknownMemberType]
|
|
313
|
+
**compact_figure_kwargs(self.compact, self.figsize)
|
|
314
|
+
)
|
|
315
|
+
# one axes over the whole figure: nothing for a layout engine to do
|
|
316
|
+
fig.set_layout_engine("none") # type: ignore[reportUnknownMemberType]
|
|
317
|
+
ax: Axes = fig.add_axes( # type: ignore[reportUnknownMemberType]
|
|
318
|
+
(0.0, 0.0, 1.0, 1.0)
|
|
319
|
+
)
|
|
320
|
+
# laid out in inches, so that the squares look square
|
|
321
|
+
width, height = (float(v) for v in fig.get_size_inches())
|
|
322
|
+
tiles = self.tiles(width, height)
|
|
323
|
+
gap = float(TREEMAP_CONFIG.get("gap_pt", 2.0))
|
|
324
|
+
for tile in tiles:
|
|
325
|
+
x, y, w, h = tile.rect
|
|
326
|
+
ax.add_patch(
|
|
327
|
+
Rectangle(
|
|
328
|
+
(x, y),
|
|
329
|
+
w,
|
|
330
|
+
h,
|
|
331
|
+
facecolor=tile.color,
|
|
332
|
+
edgecolor="white",
|
|
333
|
+
linewidth=gap,
|
|
334
|
+
)
|
|
335
|
+
)
|
|
336
|
+
ax.set_xlim(0, width)
|
|
337
|
+
ax.set_ylim(height, 0) # the first part at the top
|
|
338
|
+
ax.axis("off")
|
|
339
|
+
size = (
|
|
340
|
+
compact_font_pt(self.font_pt)
|
|
341
|
+
if self.compact
|
|
342
|
+
else self.font_pt or float(plt.rcParams["font.size"])
|
|
343
|
+
)
|
|
344
|
+
for tile in tiles:
|
|
345
|
+
self._label(fig, ax, tile, float(size or plt.rcParams["font.size"]))
|
|
346
|
+
return fig, ax
|
|
347
|
+
|
|
348
|
+
def _label(self, fig: Figure, ax: Axes, tile: Tile, size: float) -> None:
|
|
349
|
+
"""The name and figure of *tile* in its middle, as big as fits down
|
|
350
|
+
to ``min_font_scale`` of *size*; only the name if both do not fit,
|
|
351
|
+
and nothing if the name does not either."""
|
|
352
|
+
x, y, w, h = tile.rect
|
|
353
|
+
renderer: Any = fig.canvas.get_renderer() # type: ignore[attr-defined]
|
|
354
|
+
corner0 = ax.transData.transform((x, y + h))
|
|
355
|
+
corner1 = ax.transData.transform((x + w, y))
|
|
356
|
+
pad = 2 * float(TREEMAP_CONFIG.get("pad_pt", 4.0)) * fig.dpi / 72
|
|
357
|
+
room_w = corner1[0] - corner0[0] - pad
|
|
358
|
+
room_h = corner1[1] - corner0[1] - pad
|
|
359
|
+
smallest = size * float(TREEMAP_CONFIG.get("min_font_scale", 0.75))
|
|
360
|
+
figure = self.figure_text(tile)
|
|
361
|
+
for text in (f"{tile.label}\n{figure}", tile.label):
|
|
362
|
+
pt = size
|
|
363
|
+
while pt >= smallest:
|
|
364
|
+
label: Text = ax.text( # type: ignore[reportUnknownMemberType]
|
|
365
|
+
x + w / 2,
|
|
366
|
+
y + h / 2,
|
|
367
|
+
text,
|
|
368
|
+
ha="center",
|
|
369
|
+
va="center",
|
|
370
|
+
color=_text_color(tile.color),
|
|
371
|
+
fontsize=pt,
|
|
372
|
+
fontweight="bold",
|
|
373
|
+
linespacing=1.3,
|
|
374
|
+
)
|
|
375
|
+
box = label.get_window_extent(renderer) # pyright: ignore[reportUnknownArgumentType]
|
|
376
|
+
if box.width <= room_w and box.height <= room_h:
|
|
377
|
+
return
|
|
378
|
+
label.remove()
|
|
379
|
+
pt -= 0.5
|
|
@@ -119,6 +119,20 @@ sankey:
|
|
|
119
119
|
x_margin: 0.14 # margen lateral para los rótulos de los nodos
|
|
120
120
|
x_margin_two_stages: 0.2 # con solo dos columnas hay más sitio por lado
|
|
121
121
|
|
|
122
|
+
treemap:
|
|
123
|
+
# Partes de un total como rectángulos del tamaño de su peso (algoritmo
|
|
124
|
+
# squarified: lo más cuadrados posible, el mayor arriba a la izquierda).
|
|
125
|
+
dark: "#001E93" # color de la parte mayor (azul de la casa)
|
|
126
|
+
light: "#AEBAE7" # color de la menor: las demás, en degradado
|
|
127
|
+
gap_pt: 2.0 # filete blanco entre rectángulos (puntos)
|
|
128
|
+
pad_pt: 4.0 # margen del rótulo dentro de su rectángulo
|
|
129
|
+
min_font_scale: 0.75 # el rótulo encoge hasta esta fracción de la
|
|
130
|
+
# letra antes de quedarse solo con el nombre
|
|
131
|
+
share_decimals: 0 # decimales del peso (38 %)
|
|
132
|
+
luminance_threshold: 0.55 # por debajo, texto blanco
|
|
133
|
+
light_text: white
|
|
134
|
+
dark_text: "#1a1a1a"
|
|
135
|
+
|
|
122
136
|
barh:
|
|
123
137
|
highlight_factor: 0.4
|
|
124
138
|
padding: 5
|
|
@@ -113,6 +113,8 @@ _KINDS = {"grafico": _CHART, "tabla": _TABLE}
|
|
|
113
113
|
|
|
114
114
|
#: Headings whose section takes the smaller annex body.
|
|
115
115
|
_APPENDIX = re.compile(r"(?:anexo|ap[eé]ndice|referencias|bibliograf)", re.I)
|
|
116
|
+
#: Level-1 headings of the body that take no number.
|
|
117
|
+
_UNNUMBERED = re.compile(r"principales\s+mensajes", re.I)
|
|
116
118
|
#: Sections of references: left-aligned, so long addresses do not
|
|
117
119
|
#: stretch the justified lines.
|
|
118
120
|
_REFERENCES = re.compile(r"(?:referencias|bibliograf)", re.I)
|
|
@@ -153,6 +155,12 @@ def is_appendix(heading: str) -> bool:
|
|
|
153
155
|
return _APPENDIX.match(heading_text(heading)) is not None
|
|
154
156
|
|
|
155
157
|
|
|
158
|
+
def is_unnumbered(heading: str) -> bool:
|
|
159
|
+
"""A section of the body without number: the key messages, an
|
|
160
|
+
executive summary before the development."""
|
|
161
|
+
return _UNNUMBERED.fullmatch(heading_text(heading)) is not None
|
|
162
|
+
|
|
163
|
+
|
|
156
164
|
_PERCENT_UNIT = re.compile(r"\(?\s*%\s*\)?(.*)")
|
|
157
165
|
#: Abbreviated units spelled out in captions.
|
|
158
166
|
#: Abbreviated units at the start of a caption unit, and their names
|
|
@@ -666,7 +674,9 @@ class Note:
|
|
|
666
674
|
"""Heading of *level* 1 or 2 (numbered) or 3 (unnumbered).
|
|
667
675
|
|
|
668
676
|
A level-1 annex, references or bibliography heading starts a
|
|
669
|
-
section with the smaller annex body.
|
|
677
|
+
section with the smaller annex body. «Principales mensajes» is
|
|
678
|
+
the executive summary: unnumbered, so the first section of the
|
|
679
|
+
development is the 1.
|
|
670
680
|
"""
|
|
671
681
|
if level not in (1, 2, 3):
|
|
672
682
|
raise ValueError(f"nivel de título no válido: {level} (1, 2 o 3)")
|
|
@@ -682,11 +692,13 @@ class Note:
|
|
|
682
692
|
self._appendix = is_appendix(text)
|
|
683
693
|
self._references = _REFERENCES.search(text) is not None
|
|
684
694
|
paragraph = self._add(f"Heading{level}")
|
|
685
|
-
if self._appendix and level < 3
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
#
|
|
689
|
-
#
|
|
695
|
+
if (self._appendix and level < 3) or (
|
|
696
|
+
level == 1 and is_unnumbered(text)
|
|
697
|
+
):
|
|
698
|
+
# Annexes, references, bibliography and the key messages are
|
|
699
|
+
# not numbered sections («3. Anexo I» reads as a section of
|
|
700
|
+
# the body): the numbering of the style is switched off
|
|
701
|
+
# (numId 0) and so is the hanging indent left for the number.
|
|
690
702
|
pPr = _xml(paragraph)._p.get_or_add_pPr()
|
|
691
703
|
pPr.get_or_add_numPr().get_or_add_numId().val = 0
|
|
692
704
|
paragraph.paragraph_format.left_indent = Twips(0)
|