“Adicionar rótulo no choropleth mapa python” Respostas de código

Adicionar rótulo no choropleth mapa python

import plotly.express as px
import plotly.graph_objects as go
import geopandas as gpd

df = px.data.election()
geojson = px.data.election_geojson()
gdf = (
    gpd.GeoDataFrame.from_features(geojson)
    .merge(df, on="district")
    .assign(lat=lambda d: d.geometry.centroid.y, lon=lambda d: d.geometry.centroid.x)
    .set_index("district", drop=False)
)

# for convenience of rebuilding and adding traces...
def basemap():
    fig = px.choropleth_mapbox(
        df,
        geojson=geojson,
        color="Bergeron",
        locations="district",
        featureidkey="properties.district",
        center={"lat": 45.5517, "lon": -73.7073},
        mapbox_style=mapboxstyle,
#         mapbox_style="carto-positron",
        zoom=9,
    )
    fig.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0},
                      mapbox={"accesstoken":mapboxtoken}
                     )
    return fig
Horrible Hoopoe

Adicionar rótulo no choropleth mapa python

mapboxtoken="****"
mapboxstyle="mapbox://styles/***"
Horrible Hoopoe

Adicionar rótulo no choropleth mapa python

#!usr/bin/python
# encoding=utf8

import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )


import plotly.plotly as py
import pandas as pd

df = pd.read_csv('G20 data.csv')

data = [ dict(
        type = 'choropleth',
        locations = df['code'],
        z = df['article_number'],
        text = df['name'],
        #colorscale = [[0,"rgb(5, 10, 172)"],[0.35,"rgb(40, 60, 190)"],[0.5,"rgb(70, 100, 245)"],[0.6,"rgb(90, 120, 245)"],[0.7,"rgb(106, 137, 247)"],[1,"rgb(220, 220, 220)"]],
        colorscale=[[0,'#0018ad'],[0.2,'#0222e3'],[0.4,'#3f5afd'],[0.6,'#7083fb'],[0.8,'#90a0fd'],[1,'#a3b0ff']],
        autocolorscale = False,
        reversescale = True,
        marker = dict(
            line = dict (
                color = 'rgb(180,180,180)',
                width = 0.5
            ) ),
        colorbar = dict(
            autotick = False,
            tickprefix = '',
            title = 'number of articles'),
      ) ]

layout = dict(
    title = "G20 countries' scientific articles"
    geo = dict(
        showframe = False,
        showcoastlines = False,
        showlocations=True,
        showland=True,
        landcolor='#f0f0f0',
        projection = dict(type = 'Mercator')
    )
)

fig = dict( data=data, layout=layout )
py.plot( fig, validate=False, filename='d3-world-map-2')
Horrible Hoopoe

Respostas semelhantes a “Adicionar rótulo no choropleth mapa python”

Perguntas semelhantes a “Adicionar rótulo no choropleth mapa python”

Mais respostas relacionadas para “Adicionar rótulo no choropleth mapa python” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código