plotly.figure_factory.create_choropleth() function in Python

• Last Updated : 26 Jul, 2020

Plotly library of Python can be very useful for data visualization and understanding the data simply and easily.

plotly.figure_factory.create_choropleth

A Choropleth Map is a map composed of colored polygons. It is used to represent spatial variations of a quantity.

Syntax: plotly.figure_factory.create_choropleth(fips, values, scope=[‘usa’], binning_endpoints=None, colorscale=None, order=None, legend_title=”, **layout_options)

Parameters:

fips ((list)) – it describes the list of FIPS values which correspond to the con catination of state and county ids.

values ((list)) – These are the values that will determine how the counties are colored.

scope ((list)) – it describes the list of states and/or states abbreviations. Fits all states in the camera tightly.

binning_endpoints ((list)) – it describes the ascending numbers which implicitly define real number intervals which are used as bins.

colorscale ((list)) – it is a list of colors with length equal to the number of categories of colors.

Example: Choropleth a few counties in California

Python3

 import plotly.figure_factory as ff  fips = ['06021', '06023', '06027',        '06029', '06033', '06059',        '06047', '06049', '06051',        '06055', '06061']values = range(len(fips))  fig = ff.create_choropleth(fips=fips, values=values)fig.layout.template = Nonefig.show()

Output: My Personal Notes arrow_drop_up
{"ft_lang_label":"__label__en","ft_lang_prob":0.66649884,"math_prob":0.92242986,"size":1405,"snap":"2022-05-2022-21","text_gpt3_token_len":360,"char_repetition_ratio":0.1299072,"word_repetition_ratio":0.035353534,"special_character_ratio":0.27829182,"punctuation_ratio":0.1764706,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.96525806,"pos_list":[0,1,2],"im_url_duplicate_count":[null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-01-19T16:36:57Z\",\"WARC-Record-ID\":\"<urn:uuid:e13c22f9-4f2b-4d90-b36e-b4d734049a60>\",\"Content-Length\":\"111345\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c188c326-c985-4681-bf85-e0a2eb2e1e25>\",\"WARC-Concurrent-To\":\"<urn:uuid:4b8f491b-50e5-4004-a9c9-1c292361b361>\",\"WARC-IP-Address\":\"23.222.12.16\",\"WARC-Target-URI\":\"https://www.geeksforgeeks.org/plotly-figure_factory-create_choropleth-function-in-python/\",\"WARC-Payload-Digest\":\"sha1:LFSVPEF5CWBK3QJV6VQQKEUL55R7I4MB\",\"WARC-Block-Digest\":\"sha1:SI53JJOY2UHBV2EQ62GB632264I5D3PX\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-05/CC-MAIN-2022-05_segments_1642320301475.82_warc_CC-MAIN-20220119155216-20220119185216-00226.warc.gz\"}"}