8000 Merge branch 'doc-prod' · afonit/plotly.py@6fe3e5f · GitHub
[go: up one dir, main page]

Skip to content

Commit 6fe3e5f

Browse files
Merge branch 'doc-prod'
2 parents a394c58 + 718c6fd commit 6fe3e5f

File tree

3 files changed

+18
-13
lines changed
  • 3 files changed

    +18
    -13
    lines changed

    doc/python/choropleth-maps.md

    Lines changed: 8 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -6,7 +6,7 @@ jupyter:
    66
    extension: .md
    77
    format_name: markdown
    88
    format_version: '1.2'
    9-
    jupytext_version: 1.6.0
    9+
    jupytext_version: 1.4.2
    1010
    kernelspec:
    1111
    display_name: Python 3
    1212
    language: python
    @@ -20,7 +20,7 @@ jupyter:
    2020
    name: python
    2121
    nbconvert_exporter: python
    2222
    pygments_lexer: ipython3
    23-
    version: 3.7.6
    23+
    version: 3.7.7
    2424
    plotly:
    2525
    description: How to make choropleth maps in Python with Plotly.
    2626
    display_as: maps
    @@ -184,13 +184,16 @@ fig.show()
    184184
    import plotly.express as px
    185185
    import geopandas as gpd
    186186

    187-
    geo_df = gpd.read_file(gpd.datasets.get_path('nybb')).to_crs("EPSG:4326")
    187+
    df = px.data.election()
    188+
    geo_df = gpd.GeoDataFrame.from_features(
    189+
    px.data.election_geojson()["features"]
    190+
    ).merge(df, on="district").set_index("district")
    188191

    189192
    fig = px.choropleth(geo_df,
    190193
    geojson=geo_df.geometry,
    191194
    locations=geo_df.index,
    192-
    color='Shape_Leng',
    193-
    hover_name="BoroName")
    195+
    color="Joly",
    196+
    projection="mercator")
    194197
    fig.update_geos(fitbounds="locations", visible=False)
    195198
    fig.show()
    196199
    ```

    doc/python/mapbox-county-choropleth.md

    Lines changed: 7 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -165,16 +165,18 @@ fig.show()
    165165
    import plotly.express as px
    166166
    import geopandas as gpd
    167167

    168-
    geo_df = gpd.read_file(gpd.datasets.get_path('nybb')).to_crs("EPSG:4326")
    168+
    df = px.data.election()
    169+
    geo_df = gpd.GeoDataFrame.from_features(
    170+
    px.data.election_geojson()["features"]
    171+
    ).merge(df, on="district").set_index("district")
    169172

    170173
    fig = px.choropleth_mapbox(geo_df,
    171174
    geojson=geo_df.geometry,
    172175
    locations=geo_df.index,
    173-
    color='Shape_Leng',
    174-
    hover_name="BoroName",
    175-
    center={"lat": 40.71, "lon": -74.00},
    176+
    color="Joly",
    177+
    center={"lat": 45.5517, "lon": -73.7073},
    176178
    mapbox_style="open-street-map",
    177-
    zoom=8)
    179+
    zoom=8.5)
    178180
    fig.show()
    179181
    ```
    180182

    doc/requirements.txt

    Lines changed: 3 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -9,9 +9,9 @@ patsy==0.5.1
    99
    numpy==1.16.0
    1010
    plotly-geo
    1111
    python-igraph
    12-
    geopandas
    13-
    pyshp
    14-
    shapely
    12+
    geopandas==0.8.1
    13+
    pyshp==2.1.2
    14+
    shapely==1.7.1
    1515
    psutil
    1616
    requests
    1717
    networkx

    0 commit comments

    Comments
     (0)
    0