Python | Geographical plotting using plotly
Geographical plotting is used for world map as well as states under a country. Mainly used by data analysts to check the agriculture exports or to visualize such data.
plotly is a Python library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library.
cufflink connects plotly with pandas to create graphs and charts of dataframes directly. choropleth is used to describe geographical plotting of USA. choropleth is used in the plotting of world maps and many more.
Command to install plotly:
pip install plotly
Below is the implementation:
import plotly.plotly as py
import plotly.graph_objs as go
import pandas as pd
from plotly.offline import download_plotlyjs, init_notebook_mode, iplot, plot
init_notebook_mode(connected = True )
data = dict ( type = 'choropleth' ,
locations = [ 'AZ' , 'CA' , 'NY' ],
locationmode = 'USA-states' ,
colorscale = 'Portland' ,
text = [ 'text 1' , 'text 2' , 'text 3' ],
z = [ 1.0 , 2.0 , 3.0 ],
colorbar = { 'title' : 'Colorbar Title Goes Here' })
layout = dict (geo = { 'scope' : 'usa' })
choromap = go.Figure(data = [data], layout = layout)
iplot(choromap)
|
Output:
Last Updated :
26 Jun, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...