Concept
The Star Wars universe feels like a meticulously crafted world, where every character has their own history, origin, and place in the overall narrative. We remember the heroes by their actions and personalities, but behind the scenes lies another layer—a set of numbers describing their physical parameters and biological traits. Height, weight, gender, race, planet of origin—these are rarely perceived as data, yet they are what ultimately shape the structure of the fictional galaxy.
In this project, I approach «Star Wars» as a dataset, attempting to examine familiar characters from an analytical perspective. I am interested in whether there are patterns in the physical characteristics of inhabitants from different planets, whether heroes of different races vary in height and mass, and how diverse this universe truly is when measured by figures rather than storylines.
Intuitively, it seems that the franchise’s key characters are quite similar to one another—most of them are humanoids with comparable proportions. However, data analysis allows us to test this feeling and see if a more complex picture is hidden beneath the visual resemblance. Visualization helps bring these differences to the surface, transforming dry tables into tangible images and comparisons.
Data for analysis
For the analysis in this project, we use a dataset from the Kaggle platform, which contains data on characters from the Star Wars universe. The dataset is a table featuring descriptive attributes of the characters and includes information on their height and weight, gender, species, planet of origin, skin color, eye and hair color, as well as additional attributes related to their film appearances and vehicle usage.
RESEARCH QUESTION:
Can data analysis and visualization of characters from the Star Wars universe reveal patterns in their physical characteristics and origins, thereby helping us understand how diverse and structured this fictional galaxy is?
To visualize data about the characters in the Star Wars universe, several types of charts were selected to examine the dataset from various perspectives.
Pie charts are used to display the proportions of categorical features, such as the distribution of characters by gender, species, or planet of origin. This format clearly shows which groups dominate the dataset and how balanced it is.
Bar charts are employed to compare quantitative metrics across categories—for example, the average height or weight of characters from different species and planets. They allow for a quick identification of differences and a comparison between groups.
Histograms are used to analyze the distribution of numerical characteristics. They help assess typical values, data spread, and the presence of extreme or outlier observations.
A Scatter plot is applied to investigate the relationship between numerical parameters, specifically between character height and weight. It helps visually determine the presence of correlations, clusters, and anomalies within the dataset.
The signature yellow color #FFE81F, inspired by the iconic titles of the Star Wars universe, was used in the project’s visualization and design, along with the fan-created Star Wars Demolition Level font, which mimics the style of the original movie titles and lends the project a galactic atmosphere.
Data Analysis and Visualization
Importing Libraries and Loading Data
Import libraries (pandas, numpy, matplotlib, seaborn) and modules for handling paths and fonts. Suppress warnings. In Google Colab, a CSV data file is loaded and read into a DataFrame. Next, a font file is loaded, and a path to it is established for use in visualizations.
Data Preprocessing
Copying the original DataFrame, transforming the 'height' and 'mass' columns to numeric format with error handling, and filling missing values with median values. Creating dictionaries to translate the 'species', 'homeworld', 'gender', and 'eye_color' categories into Russian, and applying them to new columns (_ru). Adding a 'creature_type' column to differentiate between droids and biological species, as well as a 'force_affiliation' column to label Force users based on a list of names.
Visualization Style Configuration
Import matplotlib and add a custom font from a previously loaded file. Define a color palette dictionary themed after Star Wars (e.g., Jedi gold, Sith red). Update global rcParams for figures: size, background colors, grid and axis removal, and white labels. Create the function style_starwars_plot to customize chart axes: set titles and labels with specified fonts, colors, and spacing, hide ticks, and set a dark background.
Visualization of Entity Type Distribution and Force Affiliation
Counting the values in the creature_type and force_affiliation columns. Creating a figure with two subplots for pie charts: left—the proportion of biological species versus droids, right—Force users versus ordinary beings. Applying custom colors, autotexts with percentages and counts, bold fonts, a dark background, and a main title in Russian. Displaying the chart.
Visualization of the Top 8 Most Common Species
Counting the top 8 species from species_ru and creating a horizontal bar chart with custom colors (Rebel blue, Jedi gold), value labels on the bars. Adding text showing the total number of unique species and the percentage of people, applying the style style_starwars_plot, setting a dark background, and displaying.
Analysis of Character Growth and Mass Correlation
Filtering character data for mass > 500 kg and height < 250 cm (potentially to highlight outliers). Creating a scatter plot with data points categorized by species (Human, Droid, Wookiee, and others), utilizing custom colors, sizes, and alpha values. Adding a legend, calculating the correlation between height and mass, displaying it as text within a box, applying the style style_starwars_plot, and rendering the graph.
Visualization of the Top 7 Native Worlds for Characters
Calculating the top 7 values from homeworld_ru, creating a bar chart with custom colors (green lightsaber, Tatooine sand, etc.), white borders, and rotated axis labels. Adding gold-colored value text labels onto the bars, applying the style_starwars_plot with a Russian title and axis labels, and displaying the chart.
Visualization of Character Height Distribution
Create a histogram showing the distribution of height values from the height variable using 20 bins, colored with blue lightsaber, gold borders, and transparency. Calculate and add lines representing the mean (red, dashed) and median (green, dashed) height, including labels in Russian. Apply the style_starwars_plot style, setting the title and axis labels in Russian, and add a legend in a black-and-gold style, then compress the layout and display the plot.




