Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

add legend to px.choropleth map python

from urllib.request import urlopen
import json


with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
    counties = json.load(response)

import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv",
                   dtype={"fips": str})

import plotly.express as px

fig = px.choropleth(df, geojson=counties, locations='fips', color='unemp',
                           color_continuous_scale="Viridis",
                           range_color=(0, 12),
                           scope="usa"
                          )
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0},coloraxis_colorbar=dict(
    title="unemployment rate",
    thicknessmode="pixels",
    lenmode="pixels",
    yanchor="top",y=1,
    ticks="outside",
    tickvals=[0,4,8,12],
    ticktext=["Low", "Low Medium", "High Medium", "High"],
    dtick=4
))
fig.show()
Comment

PREVIOUS NEXT
Code Example
Python :: how to put quotes in string python 
Python :: how to make api check multiple status using drf 
Python :: network setting for virtualbox kali 
Python :: pytest rerun last failed 
Python :: host python discord bot free 
Python :: Filter by len() 
Python :: python inverse dict with repeating values 
Python :: 10.4.1.3. return Terminates Function Execution 
Python :: yaml documentation 
Python :: find mising number in O(n) 
Python :: python integrated with activeX 
Python :: how to crack a 4 way handshake with python 
Python :: cvhaardetectobjects 
Python :: Print Odd Even Negative Integer Count 
Python :: python program to get equally distributed number from given range 
Python :: pyelastic search get document 
Python :: make image to string to use in tkinter 
Python :: nlp.Defaults.stop_words.add spacy 
Python :: pandas resample fill missing values 
Python :: dip programming language 
Python :: python fibonacci sequence code 
Python :: conventional commits 
Python :: how to execute queries with cxoracle python 
Python :: disable network on pytest 
Python :: attributeerror: module 
Python :: ~coinbase api 
Python :: how to get the original start_url in scrapy 
Python :: install python3 yum centOS redhat 
Python :: python exe restart 
Python :: python math.trunc 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =