Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14215

Plotly express choropleth mexico map not showing

$
0
0

I'm working with the following pandas dataframe:

data = {'estado': {0: 'oaxaca',  1: 'nuevo león',  2: 'guerrero',  3: 'hidalgo',  4: 'baja california sur',  5: 'puebla',  6: 'nayarit',  7: 'tabasco',  8: 'baja california',  9: 'quintana roo',  10: 'michoacan de ocampo',  11: 'tamaulipas',  12: 'veracruz de ignacio de la llave',  13: 'sinaloa',  14: 'colima',  15: 'ciudad de mexico',  16: 'morelos',  17: 'veracruz de ignacio',  18: 'chiapas',  19: 'mexico',  20: 'tlaxcala',  21: 'yucatan',  22: 'durango',  23: 'chihuahua',  24: 'zacatecas',  25: 'jalisco',  26: 'coahuila de zaragoza',  27: 'san luis potosi',  28: 'aguascalientes',  29: 'campeche',  30: 'nuevo leon',  31: 'queretaro',  32: 'guanajuato',  33: 'sonora'},'percentage': {0: 0.34558823529411764,  1: 0.3333333333333333,  2: 0.3218390804597701,  3: 0.30857142857142855,  4: 0.30120481927710846,  5: 0.28860294117647056,  6: 0.2857142857142857,  7: 0.2616033755274262,  8: 0.2576530612244898,  9: 0.2483221476510067,  10: 0.23902439024390243,  11: 0.23595505617977527,  12: 0.23383084577114427,  13: 0.2289855072463768,  14: 0.22727272727272727,  15: 0.22676579925650558,  16: 0.22330097087378642,  17: 0.22186495176848875,  18: 0.21978021978021978,  19: 0.2153928380545163,  20: 0.20689655172413793,  21: 0.1980952380952381,  22: 0.19626168224299065,  23: 0.19240506329113924,  24: 0.1875,  25: 0.1852576647097195,  26: 0.18493150684931506,  27: 0.18250950570342206,  28: 0.18064516129032257,  29: 0.18007662835249041,  30: 0.17862481315396114,  31: 0.1733490566037736,  32: 0.16173570019723865,  33: 0.15902140672782875}}

And I'm trying to create a choropleth using the following code, nonetheless the map that is displayed is not showing nothing

import plotly.express as pximport requestsrepo_url = 'https://raw.githubusercontent.com/angelnmara/geojson/master/mexicoHigh.json'#Archivo GeoJSONmx_regions_geo = requests.get(repo_url).json()fig = px.choropleth(data_frame=data,                     geojson=mx_regions_geo,                     locations='estado', # nombre de la columna del Dataframe                    featureidkey='properties.name',  # ruta al campo del archivo GeoJSON con el que se hará la relación (nombre de los estados)                    color='percentage', #El color depende de las cantidades                    color_continuous_scale="burg", #greens                    #scope="north america"                   )fig.update_geos(showcountries=True, showcoastlines=True, showland=True, fitbounds="locations")fig.show()

What I want is a map from Mexico that shows color scale according to the value on percentage column. I'm verynew to plotly so any help would be great


Viewing all articles
Browse latest Browse all 14215

Trending Articles