SoFunction
Updated on 2024-10-28

Python data visualization based on pyecharts implementation of geographic charting

I. Example: Baidu Migration

Baidu Maps Chinese New Year Population Migration Data (abbreviated asBaidu's migration), a technology program launched by Baidu during the 2014 Spring Festival. Baidu Migration makes use of big data to calculate and analyze the LBS (Location Based Services) big data it owns, and the visual presentation it adopts dynamically, instantly and intuitively shows the trajectory and characteristics of the great migration of people before and after the Spring Festival in China.

web address/2021/

II. Introduction to basic grammar

grammatical

clarification

from import Geo Import map library
Geo() Pyecharts Geographic Charting
.add_map(maptype=“china“) Map Type
.add() Add Data
.set_global_opts() Setting Global Configuration Items

III. Mapping of China

Instance code:

from  import Geo
import  as opts
from commons import Faker
 
(
    Geo()
    .add_schema(maptype='china')    # Types of Chinese maps used
    .add(series_name='', data_pair=[(i, j) for i, j in zip(, ())])
    .set_global_opts(
        title_opts=(title='Map of China'),
        visualmap_opts=(
# is_piecewise=True # Discontinuous display
        )
    )
).render()

Run results:

IV. Map of China (special effects scatterplot)

Instance code:

from  import Geo
import  as opts
from  import ChartType
from commons import Faker
 
(
    Geo()
    .add_schema(maptype='china')     # Types of Chinese maps used
    .add(series_name='', data_pair=[(i, j) for i, j in zip(, ())],
        type_=ChartType.EFFECT_SCATTER)
    .set_global_opts(
        title_opts=(title='China Map(FX Scatterplot)'),
        visualmap_opts=(
            is_piecewise=True
        )
    )
).render()

Run results:

V. Mapping the geographic migration of China's population

Instance code:

from  import Geo
from  import ChartType, SymbolType
import  as opts
 
# Data construction (in tuple form)
city_num = [('Guangzhou', 105), ('Chengdu', 70), ('Beijing', 99), ('Xi'an', 80)]
start_end = [('Guangzhou', 'Chengdu'), ('Guangzhou', 'Beijing'), ('Guangzhou', 'Xi'an')]
 
(
    Geo()
    .add_schema(maptype='china', itemstyle_opts=(color='#323c48', border_color='#111')) # Map form settings
    .add('', data_pair=city_num, color='white')    # Map data color settings (dots)
    .add('', data_pair=start_end, type_=,   # Setup lines
         effect_opts=(symbol=,color='blue', symbol_size=7))   # Flow arrow drawing
).render()

Run results:

VI. Heat map: heat mapping of Guangdong map 1

Instance code:

from  import Faker
from pyecharts import options as opts
from  import Geo
from  import ChartType
 
c = (
    Geo()
    .add_schema(maptype="Guangdong", itemstyle_opts=(color="#323c48", border_color="#111"),)
    .add("",[list(z) for z in zip(Faker.guangdong_city, ())],type_=)
    .set_global_opts(
        visualmap_opts=(),
        title_opts=(title="Heat map of Guangdong"),
    )
)
 
()

Run results:

VII. Heat maps: heat mapping of Guangdong maps2

Instance code:

from  import Map
from pyecharts import options as opts
from  import ChartType
 
c = (
    Map()
    .add('', [list(z) for z in zip(Faker.guangdong_city, ())], "Guangdong")
    .set_global_opts(
        title_opts=(title="Map-Guangdong"),
        visualmap_opts=(),
    )
)
 
()

Run results:

to this article on Python data visualization based on pyecharts geographic charts to achieve the drawing of the article is introduced to this, more related to pyecharts geographic charts, please search for my previous posts or continue to browse the following related articles I hope you will support me in the future!