您好,登錄后才能下訂單哦!
本篇內容介紹了“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=["巫山縣","萬州區(qū)","云陽縣","奉節(jié)縣"] 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") )
展示中國省份,提供數(shù)據(jù)即可,展示分段型的數(shù)據(jù)按鈕,鼠標也可以控制喲,快來看看吧!
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": "阿拉伯聯(lián)合酋長國", "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.": "馬爾維納斯群島(??颂m)", "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") )
之前的那個模板是分段的,這個是連續(xù)的數(shù)據(jù)地圖,看你在什么場景進行數(shù)據(jù)可視化,有需要的這里都有喲!
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("連續(xù)數(shù)據(jù)地圖.html") )
“Python中怎么使用pyecharts繪制地理圖表”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關的知識可以關注億速云網(wǎng)站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經查實,將立刻刪除涉嫌侵權內容。