程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python- play with data - make a rolling earth

編輯:Python

One 、 Code

1、 Code

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author : sunbo time : 2022/2/21 0021
import pyecharts.options as opts
from pyecharts.charts import MapGlobe
from pyecharts.faker import POPULATION
data = [x for _, x in POPULATION[1:]]
low,high = min(data),max(data)
c=(
MapGlobe(init_opts=opts.InitOpts())
.add_schema()
.add(
maptype="world",
series_name="World Population",
data_pair=POPULATION[1:],
is_map_symbol_show=False,
label_opts=opts.LabelOpts(is_show=False),
)
.set_global_opts(visualmap_opts=opts.VisualMapOpts(
min_=low,
max_=high,
range_text=["max","min"],
is_calculable=True,
is_piecewise=True,
range_color=["lightskyblue","yellow","orangered"],
)
)
)
c.render('eath.html')

2、 Result chart

Two 、 Parameter description

In order to make the earth you like , Let's introduce the meaning of key parameters in detail :

1.POPULATION

It introduces the population of all countries in the world , So the different colors on the earth represent the number of people in each country , You can also import other data as you like .

2.theme

You can import different themes , The topic types are as follows :

themes = [ (‘chalk’, ‘ Chalk style ’), (‘dark’, ‘ Dark wind ’), (‘essos’, ‘ Aesop ’), (‘infographic’, ‘ Infographic ’), (‘light’, ‘ Bright style ’), (‘macarons’, ‘ Macaroon ’), (‘purple-passion’, ‘ Purple passion ’), (‘roma’, ‘ Pomegranate ’), (‘romantic’, ‘ Romantic style ’), (‘shine’, ‘ Shining wind ’), (‘vintage’, ‘ Retro style ’), (‘walden’, ‘ Walden pond ’), (‘westeros’, ‘ Westeros ’), (‘white’, ‘ Clean white wind ’), (‘wonderland’, ‘ Fairyland ’) ]

3.LabelOpts

Show map labels , hold False Change to True, The name of the country is displayed .

4.maptype

Change the map range , hold world Change to china; Empathy , You can also make a map of the earth that only shows Beijing and other provinces and cities .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved