From 04bbfb09a5ad1742f3e742463480280922cedb92 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 3 Jul 2024 20:27:49 +0200 Subject: [PATCH] Fix map display issues on blog output --- index.qmd | 51 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/index.qmd b/index.qmd index c143cd7..2d63d6d 100644 --- a/index.qmd +++ b/index.qmd @@ -1,5 +1,7 @@ --- title: Nuclear Explosions +subtitle: "Using python polars and seaborn to visualize global detonations" +description: "Using python polars and seaborn to visualize global detonations" references: - type: techreport id: Bergkvist2000 @@ -16,6 +18,10 @@ references: title: "Nuclear Explosions 1945 - 1998" page: 1-42 issn: 1104-9154 +pubDate: "2024-07-03T18:36:26" +weight: 10 +tags: + - python --- ```{python} @@ -45,7 +51,7 @@ country_colors = { ```{python} # | label: data-prep -# | echo: false +# | code-fold: true schema_overrides = ( { col: pl.Categorical @@ -349,8 +355,12 @@ Finally, let's view a map of the world with the explosions marked, separated by ::: {.content-visible when-format="html"} Hovering over individual explosions will show their year while a click will open more information in a panel. +The map can be seen in @fig-worldmap-html. +::: + +::: {.content-visible unless-format="html"} +The map can be seen in @fig-worldmap-static. ::: -The map can be seen in @fig-worldmap. ```{python} # | label: worldmap-setup @@ -409,29 +419,44 @@ for country in country_colors.keys(): folium.LayerControl().add_to(m) ``` -::: {#fig-worldmap} - -:::: {.content-visible when-format="html"} +::: {.content-visible when-format="html"} ```{python} -# | label: worldmap-html +# | label: fig-worldmap-html +# | fig-cap: World map of nuclear explosions, 1945-98 m ``` -:::: +::: -:::: {.content-visible unless-format="html" width=80%} +::: {.content-visible unless-format="html" width=80%} ```{python} -# | label: worldmap-non-html +# | label: fig-worldmap-static +# | fig-cap: World map of nuclear explosions, 1945-98 # ENSURE SELENIUM IS INSTALLED -m.png_enabled = True -m +from PIL import Image +from IPython.display import Image as IImage +import io +img = m._to_png() + +bimg = io.BytesIO(img) +Image.open(bimg).save("map.png") +IImage(url="map.png") ``` -:::: +::: -World map of nuclear explosions, 1945-98 +::: {.callout-warning .content-visible when-format="markdown"} +Interactive maps not working + +Unfortunately, as of right now folium maps rendered within a quarto document do +not seem to translate terribly well into an astro blog such as this. +This is why, for now, there is only a static image here. + +This is very sad, but for the time being feel free to download and peruse +the ipynb notebook [here](./index.ipynb), or the [pdf](./index.pdf) +or [docx](./index.docx) versions. ::: While there are undoubtedly more aspects of the data that provide interesting