Visualizing the World University Rankings in 2025 (Python Data Visualization)

2025년 전세계 대학교 순위 그래프
(Graph of global university rankings in 2025)

The UK's educational assessment organization Times Higher Education (THE)every year in the World University Rankingsin the United States. It uses a variety of metrics to score universities, including teaching, research, citations, international outlook, and industry revenue. It is considered an indicator of a university's global competitiveness.

In this post, we'll use the Use the 2025 global university ranking data from This course introduces how to visualize with trendy bar graphs using Python. Along the way, we'll leverage the matplotlib and seaborn libraries to create simple and intuitive visualizations.

Introduction to global university ranking data

The data we're going to visualize is a global university ranking for 2025. This data is from the UK's Times Higher Education (THE)which includes the ranking, country, name, and composite score of each university. It also includes universities from South Korea, making it easy to compare the rankings of domestic and international universities.

전세계 대학교 순위 데이터 표

Summary of key data

The top five universities worldwide are dominated by leading universities in the UK and the US. Major Asian universities are represented in the top 100, with universities from China, Japan, and South Korea, allowing for comparisons across the region. For Korean universities, Seoul National University, KAIST, Sungkyunkwan University, and Yonsei University are among the top universities in the world.

Visualize global university rankings with Python code

Now we'll clean up the global university rankings data with pandas and create a modern-style bar graph using seaborn and matplotlib. We've added explanations, including Korean annotations, to make it easier for beginners to follow along.

# Loading the required libraries
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

# Prepare the global university ranking data
data = {
    "Rank": [1, 2, 3, 4, 5, 12, 13, 28, 62, 82, 102, 102],
    "Country": ["UK", "USA", "USA", "USA", "UK", "China", "China", "Japan", "South Korea", "South Korea", "South Korea", "South Korea", "South Korea"],
    "University": ["University of Oxford", "MIT", "Harvard University", "Princeton University", "University of Cambridge",
                   "Tsinghua University", "Peking University", "University of Tokyo", "Seoul National University", "KAIST", "Sungkyunkwan University", "Yonsei University"],
    "Score": [98.5, 98.1, 97.7, 97.5, 97.4, 92.5, 92.0, 83.3, 73.5, 69.5, 66.1, 66.1]
}

Convert to # dataframe
df = pd.DataFrame(data)

Set the # graph style - use the 'whitegrid' style to create a clean background
sns.set(style="whitegrid")

Set the # graph size and draw a bar graph
plt.figure(figsize=(12, 8))
bar_plot = sns.barplot(
    x="Score", y="University", data=df, # specify 'Score' as the x-axis and 'University' as the y-axis
    palette="viridis", edgecolor=".6" # color is 'viridis' palette, bar border color is gray
)

Show rank and score at the end of a # bar graph
for index, row in df.iterrows():
    bar_plot.text(
        row["Score"] - 0.5, index, # text position (shifted slightly left from score)
        f'#{row["Rank"]} ({row["Score"]})', # text to display (rank and score)
        color='white', # Text color
        ha='right', # Right alignment
        va='center' # Vertical center alignment
    )

Set the # graph title and axis labels
bar_plot.set_title("2025 World University Rankings", fontsize=16) # Set graph title
bar_plot.set_xlabel("Score", fontsize=12) # Set the x-axis label
bar_plot.set_ylabel("University", fontsize=12) # Set the y-axis label

Show the # graph
plt.show()

Code details

Below, we've broken down what each part of the code does, specifically focusing on the part that adds the rank and score to the end of the bar graph.

#Load the necessary libraries
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

#Prepare the global university ranking data
data = {
"Rank": [1, 2, 3, 4, 5, 12, 13, 28, 62, 82, 102, 102],
"Country": ["UK", "USA", "USA", "USA", "UK", "China", "China", "Japan", "South Korea", "South Korea", "South Korea", "South Korea", "South Korea"],
"University": ["University of Oxford", "MIT", "Harvard University", "Princeton University", "University of Cambridge",
"Tsinghua University", "Peking University", "University of Tokyo", "Seoul National University", "KAIST", "Sungkyunkwan University", "Yonsei University"],
"Score": [98.5, 98.1, 97.7, 97.5, 97.4, 92.5, 92.0, 83.3, 73.5, 69.5, 66.1, 66.1]
}

#Convert to DataFrame
df = pd.DataFrame(data)
  • Import the pandas, seaborn, and matplotlib.pyplot libraries through the import statement, which are essential for creating dataframes, visualizing, and plotting graphs, respectively.
  • Define a data dictionary to store global university ranking data. It consists of the following columns: Rank, Country, University, Score.
  • Convert the data dictionary to a dataframe using pd.DataFrame(data) and store it in df. You can now use this dataframe for visualization.
#Graph Style Settings - Using the 'whitegrid' style to create a clean background
sns.set(style="whitegrid")
  • sns.set(style="whitegrid"): Add a clean background to the graph by setting the whitegrid style from the seaborn library. This style adds a shallow grid to the background to make the data stand out.
#Setting the graph size and plotting a bar graph
plt.figure(figsize=(12, 8))
bar_plot = sns.barplot(
x="Score", y="University", data=df, # Specify 'Score' as the X-axis and 'University' as the Y-axis
palette="viridis", edgecolor=".6" # color is 'viridis' palette, bar border color is gray
)
  • plt.figure(figsize=(12, 8)): Sets the size of the graph to 12 inches wide and 8 inches tall. Set the graph to an appropriate size so that it looks good on a web page or blog.
  • sns.barplot(...): Plots a bar graph using seaborn's barplot function.
  • x="Score", y="University": Set the x-axis to Score and the y-axis to University. The length of the bar will vary depending on the score, and the university name will be displayed on the y-axis.
  • data=df: Use the df dataframe for data.
  • palette="viridis": Use the viridis palette to set the color of the graph. viridis enhances the visual impact of your data with trendy colors.
  • edgecolor=".6″: Set the bar border color to gray (.6) so that the bars in the graph are well distinguished from each other.
#Show rank and score at the end of a bar graph
for index, row in df.iterrows():
bar_plot.text(
row["Score"] - 0.5, index, # text position (shifted slightly left from score)
f'#{row["Rank"]} ({row["Score"]})', # text to display (rank and score)
color='white', # Text color
ha='right', # Right alignment
va='center' # Vertical center alignment
)
  • for index, row in df.iterrows(): Traverses each row of the df dataframe, assigning the index and row data to the index and row variables, respectively. df.iterrows() is a method that allows you to iterate over each row of the dataframe.
  • bar_plot.text(...): Uses the text function to display the rank and score at the end of each bar in a bar graph.
  • row["Score"] - 0.5: Subtract -0.5 to position the X coordinate slightly to the left of the Score value. This will position the text just inside the end of the bar.
  • index: Used as the Y coordinate. The index represents the y-axis position of the row currently being iterated.
  • f'#{row["Rank"]} ({row["Score"]})': Text content, creating a string in the format #rank (score). For example, it would look something like #1 (98.5).
  • color='white': Sets the text color to white to make the text more visible inside the bar.
  • ha='right': Right-aligns the text to align with the end of the bar.
  • va='center': Sets the vertical alignment of the text to center, so that the text is centered in the height of the bar.
Setting the # graph title and axis labels
bar_plot.set_title("2025 World University Rankings", fontsize=16) # Set graph title
bar_plot.set_xlabel("Score", fontsize=12) # Set the x-axis label
bar_plot.set_ylabel("University", fontsize=12) # Set the y-axis label
  • bar_plot.set_title(...): Set the title of the graph. fontsize=16 specifies the title font size to emphasize it.
  • bar_plot.set_xlabel(...): Set the x-axis label to "Score". Set fontsize=12 to make it more readable.
  • bar_plot.set_ylabel(...): Set the y-axis label to "University" so that the name of the university appears.
Showing the # Graph
plt.show()
  • plt.show(): Prints the graph to the screen with everything set up.

Wrap up and summarize

In this post, we introduced how to visualize the 2025 global university rankings using Python. We walked you through the data visualization process step-by-step and shared some trendy graph styling tips to make your data more interesting to analyze.

This allows you to intuitively understand the rankings of universities around the world and easily compare their competitiveness. We hope you find data visualization useful and insightful in a variety of areas.

As a side note, if anyone is interested in how the fertility rate is trending, you can visualize it and get an idea of what to expect at any given point in time using the Will Korea's fertility rate rebound after a decade? The Congressional Budget Office's projections for 2025 (feat. Python) Check out the post!

Similar Posts