1. QS世界排名前200的大學(xué)都在哪里?Python動(dòng)態(tài)圖告訴你!

        共 13570字,需瀏覽 28分鐘

         ·

        2021-08-11 09:59

        今日表情 ?? :


        世界上較為主流的大學(xué)排名有美國(guó)U.S. News世界大學(xué)排名、英國(guó)QS世界大學(xué)排名、英國(guó)泰晤士高等教育世界大學(xué)排名,以及學(xué)術(shù)類(lèi)排名如世界大學(xué)自然指數(shù)排名、中國(guó)軟科世界大學(xué)學(xué)術(shù)排名等。


        我們選用的是6月份公布的2021年度英國(guó)QS世界大學(xué)排名。


        QS通過(guò)如下6個(gè)指標(biāo)對(duì)各大學(xué)進(jìn)行評(píng)估:

        • 學(xué)術(shù)聲譽(yù)(40%)

        • 雇主聲譽(yù)(10%)

        • 師生比(20%)

        • 每名教師的引用率(20%)

        • 國(guó)際教師比例(5%)

        • 留學(xué)生比例(5%)


        按照這個(gè)評(píng)估標(biāo)準(zhǔn),中國(guó)共有14所大學(xué)排進(jìn)前200名,分別是:

        15 清華大學(xué)(中國(guó))

        22 香港大學(xué)(中國(guó)香港) 

        23 北京大學(xué)(中國(guó)) 

        27 香港科技大學(xué)(中國(guó)香港) 

        34 復(fù)旦大學(xué)(中國(guó)) 

        43 香港中文大學(xué)(中國(guó)香港) 

        47 上海交通大學(xué)(中國(guó)) 

        48 香港城市大學(xué)(中國(guó)香港) 

        53 浙江大學(xué)(中國(guó)) 

        67 臺(tái)灣大學(xué)(中國(guó)臺(tái)灣) 

        75 香港理工大學(xué)(中國(guó)香港) 

        94 中國(guó)科學(xué)技術(shù)大學(xué)(中國(guó)) 

        126 南京大學(xué)(中國(guó)) 

        168 國(guó)立清華大學(xué)(中國(guó)臺(tái)灣)


        那么,QS排名前200名的這些世界頂級(jí)大學(xué)都在哪里呢?我們用Python動(dòng)態(tài)圖來(lái)盤(pán)點(diǎn)一下吧!


        先上圖片


        再上視頻



        最后上代碼


        import numpy as np 
        import pandas as pd 
        import geopandas as gpd 
        import shapely 
        from shapely import geometry as geo 
        from shapely import wkt 
        import geopandas as gpd 
        import matplotlib.pyplot as plt 
        import matplotlib.animation as  animation 
        import contextily as ctx 

        import imageio
        import os 
        from PIL import Image

        plt.rcParams['font.family'] = 'sans-serif'
        plt.rcParams['font.sans-serif'] = ['SimHei']
        plt.rcParams['axes.unicode_minus'] = False
        plt.rcParams['animation.writer'] = 'html'
        plt.rcParams['animation.embed_limit'] = 100

        def rgba_to_rgb(img_rgba):
            img_rgb = Image.new("RGB", img_rgba.size, (255255255))
            img_rgb.paste(img_rgba, mask=img_rgba.split()[3]) 
            return img_rgb 

        def html_to_gif(html_file, gif_file, duration=0.5):
            path = html_file.replace(".html","_frames")
            images = [os.path.join(path,x) for x in sorted(os.listdir(path))]
            frames = [imageio.imread(x) for x in images]
            if frames[0].shape[-1]==4:
                frames = [np.array(rgba_to_rgb(Image.fromarray(x))) for x in frames]
            imageio.mimsave(gif_file, frames, 'gif', duration=duration)
            return gif_file

        cmap = [
        '#2E91E5',
        '#1CA71C',
        '#DA16FF',
        '#B68100',
        '#EB663B',
        '#00A08B',
        '#FC0080',
        '#6C7C32',
        '#862A16',
        '#620042',
        '#DA60CA',
        '#0D2A63']*100

        def getCoords(geom):
            if isinstance(geom,geo.MultiPolygon):
                return [np.array(g.exterior) for g in geom.geoms]
            elif isinstance(geom,geo.Polygon):
                return [np.array(geom.exterior)]
            elif isinstance(geom,geo.LineString):
                return [np.array(geom)]
            elif isinstance(geom,geo.MultiLineString):
                return [np.array(x) for x in list(geom.geoms)]
            else:
                raise Exception("geom must be one of [polygon,MultiPolygon,LineString,MultiLineString]!")

        #底圖數(shù)據(jù)
        dfcoutries = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres')).set_crs("epsg:4326")

        #散點(diǎn)數(shù)據(jù)
        dfpoints = gpd.read_file("./data/QS世界大學(xué)排名前200.geojson")
        df = pd.DataFrame({"x":[pt.x for pt in dfpoints["geometry"]],
                          "y": [pt.y for pt in dfpoints["geometry"]]})

        df["z"] = 1.0
        df.index = dfpoints["name"].values

        def bubble_map_dance(df,title = "QS世界排名前200大學(xué)分布",
                             filename = None,
                             figsize = (8,6),dpi = 144,
                             duration = 0.5,
                             anotate_points = [])
        :


            fig, ax_base =plt.subplots(figsize=figsize,dpi=dpi)

            def plot_frame(i):
                ax_base.clear()

                #============================================================
                #繪制底圖
                #============================================================

                dfcoutries.plot(ax=ax_base,color='white',edgecolor='gray',alpha = 0.5

                #設(shè)置繪圖范圍
                ax_base.set_xlim(-198.0198.00000000000009)
                ax_base.set_ylim(-98.6822564999999892.3273865)
                ax_base.axis("off")


                #============================================================
                #繪制散點(diǎn)
                #============================================================

                k = i//3+1
                m = i%3
                text = "NO."+str(len(df)+1-k) 

                dfdata = df.iloc[:k,:].copy()
                dftmp = df.iloc[:k-1,:].copy()

                # 繪制散點(diǎn)圖像
                if len(dftmp)>0:
                    ax_base.scatter(dftmp["x"],dftmp["y"],s = 40*dftmp["z"]/df["z"].mean(),
                           c = (cmap*100)[0:len(dftmp)],alpha = 0.4,zorder = 3)

                    # 添加注釋文字
                    for i,p in enumerate(dftmp.index):
                        px,py,pz = dftmp.loc[p,["x","y","z"]].tolist() 
                        if p in anotate_points:
                            ax_base.annotate(p,xy = (px,py),  xycoords = "data",xytext = (-15,10),
                            fontsize = 10,fontweight = "bold",color = cmap[i], textcoords = "offset points")

                # 添加標(biāo)題和排名序號(hào)
                ax_base.set_title(title,color = "black",fontsize = 12)
                #ax_base.text(0.5, 0.95, title, va="center", ha="center", 
                #            size = 12,transform = ax_base.transAxes)
                ax_base.text(0.170.3, text, va="center", ha="center"
                             alpha=0.4, size = 40,transform = ax_base.transAxes)

                # 添加注意力動(dòng)畫(huà)
                if m==0:
                    px,py,pz = dfdata["x"][[-1]],dfdata["y"][[-1]],dfdata["z"][-1]
                    p = dfdata.index[-1]
                    ax_base.scatter(px,py,s = 200*pz/df["z"].mean(),
                       c = cmap[len(dfdata)-1:len(dfdata)],alpha = 0.4,zorder = 4)
                    ax_base.annotate(p,xy = (px,py),  xycoords = "data",
                            xytext = (-15,10),fontsize = 15,fontweight = "bold",
                            color = cmap[k-1], textcoords = "offset points",zorder = 5)

                if m==1:
                    px,py,pz = dfdata["x"][[-1]],dfdata["y"][[-1]],dfdata["z"][-1]
                    p = dfdata.index[-1]
                    ax_base.scatter(px,py,s = 100*pz/df["z"].mean(),
                       c = cmap[len(dfdata)-1:len(dfdata)],alpha = 0.4,zorder = 4)
                    ax_base.annotate(p,xy = (px,py),  xycoords = "data",
                            xytext = (-15,10),fontsize = 12,fontweight = "bold",
                            color = cmap[k-1], textcoords = "offset points",zorder = 5)

                if m==2:
                    px,py,pz = dfdata["x"][[-1]],dfdata["y"][[-1]],dfdata["z"][-1]
                    p = dfdata.index[-1]
                    ax_base.scatter(px,py,s = 40*pz/df["z"].mean(),
                       c = cmap[len(dfdata)-1:len(dfdata)],alpha = 0.4,zorder = 4)
                    ax_base.annotate(p,xy = (px,py),  xycoords = "data",
                            xytext = (-15,10),fontsize = 9,fontweight = "bold",
                            color = cmap[k-1], textcoords = "offset points",zorder = 5)
                        
            my_animation = animation.FuncAnimation(fig,plot_frame,frames = range(0,3*len(df)),interval = int(duration*1000))
            
            if filename is None:
                try:
                    from IPython.display import HTML
                    HTML(my_animation.to_jshtml())
                    return HTML(my_animation.to_jshtml())
                except ImportError:
                    pass
            else:
                my_animation.save(filename)
                return filename
            

        html_file = "QS世界排名前200大學(xué)分布.html"
        bubble_map_dance(df,filename = html_file)

        gif_file = html_file.replace(".html",".gif")
        html_to_gif(html_file,gif_file,duration=0.5)


        收工。??


        萬(wàn)水千山總是情,點(diǎn)個(gè)在看行不行???

        瀏覽 45
        點(diǎn)贊
        評(píng)論
        收藏
        分享

        手機(jī)掃一掃分享

        分享
        舉報(bào)
        評(píng)論
        圖片
        表情
        推薦
        點(diǎn)贊
        評(píng)論
        收藏
        分享

        手機(jī)掃一掃分享

        分享
        舉報(bào)
          
          

            1. 淫香淫色图片 | 青青草原亚洲 | 青青操网 | 天天综合~永久入口 | 欧美大片18禁 |