Fix map display issues on blog output

This commit is contained in:
Marty Oehme 2024-07-03 20:27:49 +02:00
parent 4ec27ed73b
commit 04bbfb09a5
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -1,5 +1,7 @@
--- ---
title: Nuclear Explosions title: Nuclear Explosions
subtitle: "Using python polars and seaborn to visualize global detonations"
description: "Using python polars and seaborn to visualize global detonations"
references: references:
- type: techreport - type: techreport
id: Bergkvist2000 id: Bergkvist2000
@ -16,6 +18,10 @@ references:
title: "Nuclear Explosions 1945 - 1998" title: "Nuclear Explosions 1945 - 1998"
page: 1-42 page: 1-42
issn: 1104-9154 issn: 1104-9154
pubDate: "2024-07-03T18:36:26"
weight: 10
tags:
- python
--- ---
```{python} ```{python}
@ -45,7 +51,7 @@ country_colors = {
```{python} ```{python}
# | label: data-prep # | label: data-prep
# | echo: false # | code-fold: true
schema_overrides = ( schema_overrides = (
{ {
col: pl.Categorical 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"} ::: {.content-visible when-format="html"}
Hovering over individual explosions will show their year Hovering over individual explosions will show their year
while a click will open more information in a panel. 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} ```{python}
# | label: worldmap-setup # | label: worldmap-setup
@ -409,29 +419,44 @@ for country in country_colors.keys():
folium.LayerControl().add_to(m) folium.LayerControl().add_to(m)
``` ```
::: {#fig-worldmap} ::: {.content-visible when-format="html"}
:::: {.content-visible when-format="html"}
```{python} ```{python}
# | label: worldmap-html # | label: fig-worldmap-html
# | fig-cap: World map of nuclear explosions, 1945-98
m m
``` ```
:::: :::
:::: {.content-visible unless-format="html" width=80%} ::: {.content-visible unless-format="html" width=80%}
```{python} ```{python}
# | label: worldmap-non-html # | label: fig-worldmap-static
# | fig-cap: World map of nuclear explosions, 1945-98
# ENSURE SELENIUM IS INSTALLED # ENSURE SELENIUM IS INSTALLED
m.png_enabled = True from PIL import Image
m 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 While there are undoubtedly more aspects of the data that provide interesting