Python chunk doesn't show the basemap generated by the contextily package

In a rmarkdown document, it can normally show the plot generated by matplotlib inline.

However, when it comes to the basemap generated by contextily, there's no inline output:

```{r setup}
library(reticulate)
# conda_create("r-reticulate")
use_condaenv("r-reticulate")
```
```{python}
import contextily as cx
import geopandas
import rasterio
from rasterio.plot import show as rioshow
import matplotlib.pyplot as plt

data_url = "https://ndownloader.figshare.com/files/20232174"
db = geopandas.read_file(data_url)
```
```{python}
ax = db.plot(color="red", figsize=(9, 9))
cx.add_basemap(ax, crs=db.crs.to_string())
```

May I ask how to solve this issue? My python version is 3.10.4.

Your kind guidance is much appreciated!

It is possible that there is a different support needed for contextily output.

You can probably open an issue in GitHub - rstudio/reticulate: R Interface to Python posting a reproducible example for the developer to check this.

Thanks for your quick response @cderv! Issue opened.

1 Like

Great. For reference, this has been opened here

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.