Python繪制地理圖表可視化神器pyecharts
地圖
這期文章我們一起來看看地圖是如何繪制的,如何在地圖裡面添加數據進行多維度的展示,下面我們一起來感受一下地圖的魅力吧!
“地圖就是依據一定的數學法則,使用制圖語言,通過制圖綜合,在一定的載體上,表達地球(或其他天體)上各種事物的空間分佈、聯系及時間中的發展變化狀態的圖形. 地圖的特征包括:由於特殊的數學法則而產生的可量測性;由於使用符號表象事物而產生的直觀性;由於制圖綜合而產生的一覽性. 地圖的三要素是:比例尺、方向、圖例 地圖學是研究地圖的理論、編制技術與應用方法的科學,是一門研究以地圖圖形反映與揭示各種自然和社會現象空間分佈、相互聯系及動態變化的科學、技術與藝術相結合的科學.”
讀萬卷書不如行萬裡路,讓我們一起看看祖國的大好山河吧!
地圖模板系列
中國地圖
展示中國的所有省份,一個完全的中國簡單的地理圖形,方便你理解城市的分佈位置喲!
from pyecharts import options as opts from pyecharts.charts import Map from pyecharts.faker import Faker c = ( Map() .add("城市", [list(z) for z in zip(Faker.provinces, Faker.values())], "china") .set_global_opts(title_opts=opts.TitleOpts(title="中國地圖")) .render("中國地圖.html") ) print([list(z) for z in zip(Faker.provinces, Faker.values())])
省份數據地圖(重慶地圖)
重慶地圖的展示,添加瞭區縣的數據即可,快來看看重慶有哪些好玩的地方吧,聽說主城區的洪崖洞還不錯,夜景那是非常好看的,來吧我們一起來看看吧!
from pyecharts import options as opts from pyecharts.charts import Map from pyecharts.faker import Faker x=["巫山縣","萬州區","雲陽縣","奉節縣"] y=[123,560,456,362] c = ( Map(init_opts=opts.InitOpts(width="1400px", height="700px")) .add("城市", [list(z) for z in zip(x,y)], "重慶") .set_global_opts( title_opts=opts.TitleOpts(title="重慶地圖"), visualmap_opts=opts.VisualMapOpts(max_=560) ) .render("重慶地圖.html") )
中國城市地圖數據地圖(分段型)
展示中國省份,提供數據即可,展示分段型的數據按鈕,鼠標也可以控制喲,快來看看吧!
from pyecharts import options as opts from pyecharts.charts import Map from pyecharts.faker import Faker c = ( Map(init_opts=opts.InitOpts(width="1400px", height="700px")) .add("城市", [list(z) for z in zip(Faker.provinces, Faker.values())], "china") .set_global_opts( title_opts=opts.TitleOpts(title="中國人口地圖)"), visualmap_opts=opts.VisualMapOpts(max_=200, is_piecewise=True), ) .render("中國分段地圖.html") )
世界地圖
需要註意的是我們要知道每個國傢英文名字,註意和pyecharts的map()語言一樣,不然就不行瞭。
這裡提供官方對照表喲,這也太強瞭吧!
{ "Somalia": "索馬裡", "Liechtenstein": "列支敦士登", "Morocco": "摩洛哥", "W. Sahara": "西撒哈拉", "Serbia": "塞爾維亞", "Afghanistan": "阿富汗", "Angola": "安哥拉", "Albania": "阿爾巴尼亞", "Andorra": "安道爾共和國", "United Arab Emirates": "阿拉伯聯合酋長國", "Argentina": "阿根廷", "Armenia": "亞美尼亞", "Australia": "澳大利亞", "Austria": "奧地利", "Azerbaijan": "阿塞拜疆", "Burundi": "佈隆迪", "Belgium": "比利時", "Benin": "貝寧", "Burkina Faso": "佈基納法索", "Bangladesh": "孟加拉國", "Bulgaria": "保加利亞", "Bahrain": "巴林", "Bahamas": "巴哈馬", "Bosnia and Herz.": "波斯尼亞和黑塞哥維那", "Belarus": "白俄羅斯", "Belize": "伯利茲", "Bermuda": "百慕大", "Bolivia": "玻利維亞", "Brazil": "巴西", "Barbados": "巴巴多斯", "Brunei": "文萊", "Bhutan": "不丹", "Botswana": "博茨瓦納", "Central African Rep.": "中非", "Canada": "加拿大", "Switzerland": "瑞士", "Chile": "智利", "China": "中國", "Côte d'Ivoire": "科特迪瓦", "Cameroon": "喀麥隆", "Dem. Rep. Congo": "剛果民主共和國", "Congo": "剛果", "Colombia": "哥倫比亞", "Cape Verde": "佛得角", "Costa Rica": "哥斯達黎加", "Cuba": "古巴", "N. Cyprus": "北塞浦路斯", "Cyprus": "塞浦路斯", "Czech Rep.": "捷克", "Germany": "德國", "Djibouti": "吉佈提", "Denmark": "丹麥", "Dominican Rep.": "多米尼加", "Algeria": "阿爾及利亞", "Ecuador": "厄瓜多爾", "Egypt": "埃及", "Eritrea": "厄立特裡亞", "Spain": "西班牙", "Estonia": "愛沙尼亞", "Ethiopia": "埃塞俄比亞", "Finland": "芬蘭", "Fiji": "斐濟", "France": "法國", "Gabon": "加蓬", "United Kingdom": "英國", "Georgia": "格魯吉亞", "Ghana": "加納", "Guinea": "幾內亞", "Gambia": "岡比亞", "Guinea-Bissau": "幾內亞比紹", "Eq. Guinea": "赤道幾內亞", "Greece": "希臘", "Grenada": "格林納達", "Greenland": "格陵蘭", "Guatemala": "危地馬拉", "Guam": "關島", "Guyana": "圭亞那", "Honduras": "洪都拉斯", "Croatia": "克羅地亞", "Haiti": "海地", "Hungary": "匈牙利", "Indonesia": "印度尼西亞", "India": "印度", "Br. Indian Ocean Ter.": "英屬印度洋領土", "Ireland": "愛爾蘭", "Iran": "伊朗", "Iraq": "伊拉克", "Iceland": "冰島", "Israel": "以色列", "Italy": "意大利", "Jamaica": "牙買加", "Jordan": "約旦", "Japan": "日本", "Siachen Glacier": "錫亞琴冰川", "Kazakhstan": "哈薩克斯坦", "Kenya": "肯尼亞", "Kyrgyzstan": "吉爾吉斯坦", "Cambodia": "柬埔寨", "Korea": "韓國", "Kuwait": "科威特", "Lao PDR": "老撾", "Lebanon": "黎巴嫩", "Liberia": "利比裡亞", "Libya": "利比亞", "Sri Lanka": "斯裡蘭卡", "Lesotho": "萊索托", "Lithuania": "立陶宛", "Luxembourg": "盧森堡", "Latvia": "拉脫維亞", "Moldova": "摩爾多瓦", "Madagascar": "馬達加斯加", "Mexico": "墨西哥", "Macedonia": "馬其頓", "Mali": "馬裡", "Malta": "馬耳他", "Myanmar": "緬甸", "Montenegro": "黑山", "Mongolia": "蒙古", "Mozambique": "莫桑比克", "Mauritania": "毛裡塔尼亞", "Mauritius": "毛裡求斯", "Malawi": "馬拉維", "Malaysia": "馬來西亞", "Namibia": "納米比亞", "New Caledonia": "新喀裡多尼亞", "Niger": "尼日爾", "Nigeria": "尼日利亞", "Nicaragua": "尼加拉瓜", "Netherlands": "荷蘭", "Norway": "挪威", "Nepal": "尼泊爾", "New Zealand": "新西蘭", "Oman": "阿曼", "Pakistan": "巴基斯坦", "Panama": "巴拿馬", "Peru": "秘魯", "Philippines": "菲律賓", "Papua New Guinea": "巴佈亞新幾內亞", "Poland": "波蘭", "Puerto Rico": "波多黎各", "Dem. Rep. Korea": "朝鮮", "Portugal": "葡萄牙", "Paraguay": "巴拉圭", "Palestine": "巴勒斯坦", "Qatar": "卡塔爾", "Romania": "羅馬尼亞", "Russia": "俄羅斯", "Rwanda": "盧旺達", "Saudi Arabia": "沙特阿拉伯", "Sudan": "蘇丹", "S. Sudan": "南蘇丹", "Senegal": "塞內加爾", "Singapore": "新加坡", "Solomon Is.": "所羅門群島", "Sierra Leone": "塞拉利昂", "El Salvador": "薩爾瓦多", "Suriname": "蘇裡南", "Slovakia": "斯洛伐克", "Slovenia": "斯洛文尼亞", "Sweden": "瑞典", "Swaziland": "斯威士蘭", "Seychelles": "塞舌爾", "Syria": "敘利亞", "Chad": "乍得", "Togo": "多哥", "Thailand": "泰國", "Tajikistan": "塔吉克斯坦", "Turkmenistan": "土庫曼斯坦", "Timor-Leste": "東帝汶", "Tonga": "湯加", "Trinidad and Tobago": "特立尼達和多巴哥", "Tunisia": "突尼斯", "Turkey": "土耳其", "Tanzania": "坦桑尼亞", "Uganda": "烏幹達", "Ukraine": "烏克蘭", "Uruguay": "烏拉圭", "United States": "美國", "Uzbekistan": "烏茲別克斯坦", "Venezuela": "委內瑞拉", "Vietnam": "越南", "Vanuatu": "瓦努阿圖", "Yemen": "也門", "South Africa": "南非", "Zambia": "贊比亞", "Zimbabwe": "津巴佈韋", "Aland": "奧蘭群島", "American Samoa": "美屬薩摩亞", "Fr. S. Antarctic Lands": "南極洲", "Antigua and Barb.": "安提瓜和巴佈達", "Comoros": "科摩羅", "Curaçao": "庫拉索島", "Cayman Is.": "開曼群島", "Dominica": "多米尼加", "Falkland Is.": "馬爾維納斯群島(福克蘭)", "Faeroe Is.": "法羅群島", "Micronesia": "密克羅尼西亞", "Heard I. and McDonald Is.": "赫德島和麥克唐納群島", "Isle of Man": "曼島", "Jersey": "澤西島", "Kiribati": "基裡巴斯", "Saint Lucia": "聖盧西亞", "N. Mariana Is.": "北馬裡亞納群島", "Montserrat": "蒙特塞拉特", "Niue": "紐埃", "Palau": "帕勞", "Fr. Polynesia": "法屬波利尼西亞", "S. Geo. and S. Sandw. Is.": "南喬治亞島和南桑威奇群島", "Saint Helena": "聖赫勒拿", "St. Pierre and Miquelon": "聖皮埃爾和密克隆群島", "São Tomé and Principe": "聖多美和普林西比", "Turks and Caicos Is.": "特克斯和凱科斯群島", "St. Vin. and Gren.": "聖文森特和格林納丁斯", "U.S. Virgin Is.": "美屬維爾京群島", "Samoa": "薩摩亞" }
from pyecharts import options as opts from pyecharts.charts import Map from pyecharts.faker import Faker c = ( Map(init_opts=opts.InitOpts(width="1400px", height="700px")) .add("國傢", [list(z) for z in zip(Faker.country, Faker.values())], "world") .set_series_opts(label_opts=opts.LabelOpts(is_show=False)) .set_global_opts( title_opts=opts.TitleOpts(title="世界地圖"), visualmap_opts=opts.VisualMapOpts(max_=200), ) .render("世界地圖.html") )
中國地圖帶城市(詳細)
如果你想要知道中國地圖,但是也要知道祖國的板塊輪廓,可以用這個模板喲!
from pyecharts import options as opts from pyecharts.charts import Map from pyecharts.faker import Faker c = ( Map(init_opts=opts.InitOpts(width="1400px", height="700px")) .add( "城市", [list(z) for z in zip(Faker.guangdong_city, Faker.values())], "china-cities", label_opts=opts.LabelOpts(is_show=False), ) .set_global_opts( title_opts=opts.TitleOpts(title="中國地圖(帶城市)"), visualmap_opts=opts.VisualMapOpts(), ) .render("中國地圖帶城市.html") )
中國連續數據地圖
之前的那個模板是分段的,這個是連續的數據地圖,看你在什麼場景進行數據可視化,有需要的這裡都有喲!
from pyecharts import options as opts from pyecharts.charts import Map from pyecharts.faker import Faker c = ( Map(init_opts=opts.InitOpts(width="1400px", height="700px")) .add("城市", [list(z) for z in zip(Faker.provinces, Faker.values())], "china") .set_global_opts( title_opts=opts.TitleOpts(title="(標題)"), visualmap_opts=opts.VisualMapOpts(max_=200), ) .render("連續數據地圖.html") )
復雜地圖觀賞
到此這篇關於Python繪制地理圖表可視化神器pyecharts的文章就介紹到這瞭,更多相關Python繪制神器pyecharts內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!
推薦閱讀:
- Python可視化神器pyecharts繪制地理圖表
- Python數據可視化之基於pyecharts實現的地理圖表的繪制
- Python繪制散點圖之可視化神器pyecharts
- Python可視化神器pyecharts繪制儀表盤
- Python可視化神器pyecharts繪制餅狀圖