.. only:: html
.. note::
:class: sphx-glr-download-link-note
Click :ref:`here ` to download the full example code
.. rst-class:: sphx-glr-example-title
.. _sphx_glr_auto_examples_plot_choropleth_map_unemployment_by_state.py:
Unemployment rate by state
==========================
In this example we'll visualize the most recent data on
brazilian unemployment per state.
Let's again retrieve the data with the `seriesbr `_ package.
.. code-block:: default
from seriesbr import ibge
df = ibge.get_series(
4095, 4099, last_n=1, states=True
)
Now let's convert this ``DataFrame`` into a ``GeoDataFrame`` after getting the
geometric objects for each state.
.. code-block:: default
import geopandas as gpd
from mapsbr import ibgemaps
df = df.assign(geometry=ibgemaps.geocode(df["Unidade da Federação (Código)"]))
gdf = gpd.GeoDataFrame(df)
Now let's plot it.
.. code-block:: default
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.axis("off")
gdf.plot(column="Valor", cmap="OrRd", legend=True, ax=ax)
plt.show()
.. image:: /auto_examples/images/sphx_glr_plot_choropleth_map_unemployment_by_state_001.png
:class: sphx-glr-single-img
.. rst-class:: sphx-glr-timing
**Total running time of the script:** ( 0 minutes 10.393 seconds)
**Estimated memory usage:** 9 MB
.. _sphx_glr_download_auto_examples_plot_choropleth_map_unemployment_by_state.py:
.. only :: html
.. container:: sphx-glr-footer
:class: sphx-glr-footer-example
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download Python source code: plot_choropleth_map_unemployment_by_state.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_choropleth_map_unemployment_by_state.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_