Python |使用plotly进行地理绘图

地理绘图用于绘制世界地图以及国家下的州。主要用于数据分析师检查农业出口或可视化此类数据。

null

阴谋地 是一个Python库,用于设计图形,尤其是交互式图形。它可以绘制各种图形和图表,如直方图、条形图、箱线图、扩展图等。它主要用于数据分析和财务分析。 阴谋地 是一个交互式可视化库。

袖扣 plotly与pandas连接,直接创建数据帧的图形和图表。 等值线图 用于描述美国的地理绘图。choropleth用于绘制世界地图等。

用于plotly安装的命令:

pip install plotly 

以下是实施情况:

# Python program to plot
# geographical data using plotly
# importing all necessary libraries
import plotly.plotly as py
import plotly.graph_objs as go
import pandas as pd
# some more libraries to plot graph
from plotly.offline import download_plotlyjs, init_notebook_mode, iplot, plot
# To establish connection
init_notebook_mode(connected = True )
# type defined is choropleth to
# plot geographical plots
data = dict ( type = 'choropleth' ,
# location: Arizoana, California, Newyork
locations = [ 'AZ' , 'CA' , 'NY' ],
# States of USA
locationmode = 'USA-states' ,
# colorscale can be added as per requirement
colorscale = 'Portland' ,
# text can be given anything you like
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' })
# passing data dictionary as a list
choromap = go.Figure(data = [data], layout = layout)
# plotting graph
iplot(choromap)


输出: map

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享