In the Jupyter Notebook, using geopandas, the x- y-axis is not showing

Viewed 79
import geopandas
    
map_df = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
map_df.plot()

Error Traceback and Output:

enter image description here

1 Answers

The map has a transparent background where the axes are. Since the axes are black by default and your background is also black, you can't see them. But they are there :).

You can specify the background using matplotlib.

import geopandas
import matplotlib.pyplot as plt

map_df = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))

fig, ax = plt.subplots()
ax = map_df.plot(ax=ax)
fig.patch.set_facecolor('pink')

result

Related