5 Data Visualization Techniques That Wow

5 Data Visualization Techniques That Wow

I don’t want to bash standard data plots like bar and line plots. They do have their purpose and never think of simplicity as something to run from. In many use cases, creating and customizing a bar or a line plot is exactly what you need. Anything else would be an overkill.

However, data and desired insights sometimes call for less-used plots that wow. These wow not only because they look cool but also because they provide insights that other visualizations can’t.

1. Heatmaps for Correlation Analysis (seaborn)

Description: Heatmaps are very intuitive and easy to read when showing the relationship between variables. That makes them perfect for correlation analysis.

Code example: You can create heatmaps easily using seaborn. The example is the code below that shows correlations for the Treadmill Buyer Profile data project.

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

fig, ax = plt.subplots(figsize = (10,10))
sns.set(color_codes = True)
sns.heatmap(aerofit_df.corr(), ax=ax, annot = True, linewidths = 0.05, fmt ='0.2f')
plt.show()

Visualization example: The code above will produce this heatmap.

Heatmaps for Correlation Analysis in Data Visualization Techniques

2. Animated Plots for Time-Series Data (Matplotlib + FuncAnimation)

Description: It’s all well creating static plots, but if you want to wow yourself and others, animate your plots using the FuncAnimation module in Matplotlib. Such plots are particularly suited for displaying time series (especially with real-time data) due to their sequentiality.

Code example: 

import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import matplotlib.dates as mdates
import matplotlib.ticker as ticker
import matplotlib

matplotlib.use('TkAgg')

data_path = 'C:/Users/babic/deposit_data.csv'
data = pd.read_csv(data_path)
data['deposit_date'] = pd.to_datetime(data['deposit_date'], errors='coerce')
data = data.dropna(subset=['deposit_date', 'deposit_amount'])
data['deposit_amount'] = data['deposit_amount'].astype(float)
grouped_data = data.groupby('deposit_date', as_index=False)['deposit_amount'].sum()

x = grouped_data['deposit_date']
y = grouped_data['deposit_amount']

fig, ax = plt.subplots(figsize=(10, 6))
ax.set_title("Total Deposit Amount Over Time", fontsize=14)
ax.set_xlabel("Date", fontsize=12)
ax.set_ylabel("Total Deposits (USD)", fontsize=12)  # Specify units in the label
line, = ax.plot([], [], color="blue", lw=2)

ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m'))
ax.xaxis.set_major_locator(mdates.MonthLocator(interval=1))
fig.autofmt_xdate()

def format_yaxis(value, _):
    return f"${value:,.0f}" 
ax.yaxis.set_major_formatter(ticker.FuncFormatter(format_yaxis))

def init():
    ax.set_xlim(x.iloc[0], x.iloc[-1])
    ax.set_ylim(0, y.max() * 1.1)
    line.set_data([], [])
    return line,

def update(frame):
    line.set_data(x.iloc[:frame], y.iloc[:frame])
    return line,

ani = FuncAnimation(fig, update, frames=len(x), init_func=init, blit=True, repeat=False)
plt.show()

Visualization example: The code will display the animated plot showing the total deposit amount over time.

Data Visualization Technique of Animated Plots for Time Series

3. Geospatial Visualizations (Plotly + GeoPandas)

Description: If you’re analyzing geographic data, it’s logical that you want to show it on a map. You can use GeoPandas and Plotly to create interactive and customized choropleth maps. That way, you can make your analysis highly engaging.

Code example: This code uses the Admin 0 – Details dataset from Natural Earth.

import geopandas as gpd
import plotly.express as px

shapefile_path = "C:/Users/StrataScratch/ne_10m_admin_0_sovereignty/ne_10m_admin_0_sovereignty.shp"
world = gpd.read_file(shapefile_path)

fig = px.choropleth(
    world,
    geojson=world.geometry,
    locations=world.index,
    color="GDP_MD",
    title="Global GDP Visualization",
    hover_name="ADMIN",
    projection="natural earth"
)

fig.update_geos(fitbounds="locations", visible=False)
fig.show()

Visualization example: The code creates this interactive world map, with each country colored by the GDP level.

Geospatial Data Visualization Technique

4. Ridgeline Plots for Distribution Trends (JoyPy)

Description: Ridgeline plots show distributions in a layered format, which is great for showing distribution trends across multiple datasets or categories over a shared axis. Ridgeline plots are very suitable when working with data that changes over time, across categories, or within groups. You can create these plots using JoyPy.

Code example: Here’s the code example that uses the OECD Income Distribution Database (IDD) to make the ridgeline plot.

import pandas as pd
import joypy
import matplotlib.pyplot as plt

file_path = "C:/Users/StrataScratch/OECD.WISE.INE,DSD_WISE_IDD@DF_IDD,1.0+.A.INC_DISP_GINI..._T.METH2012.D_CUR..csv"
data = pd.read_csv(file_path)

filtered_data = data[["Reference area", "OBS_VALUE"]].dropna()

top_countries = (
    filtered_data["Reference area"].value_counts().head(10).index
)
filtered_data = filtered_data[filtered_data["Reference area"].isin(top_countries)]

joypy.joyplot(
    data=filtered_data,
    by="Reference area",
    column="OBS_VALUE",
    colormap=plt.cm.coolwarm,
    title="Ridgeline Plot of GINI Index for Top 10 Countries",
    overlap=1.5
)

plt.show()

Visualization example: The code outputs a ridgeline plot showing the top 10 countries according to their GINI index.

Data Visualization Technique of Ridgeline Plots for Distribution Trends

5. Network Graphs for Relationships (NetworkX + Matplotlib)

Description: Network graphs are very useful for understanding relationships in data (e.g., social connections or organizational hierarchies). You can create these graphs with the NetworkX library.

Code example: This code creates a simplified network graph using the ego-Facebook dataset.

import networkx as nx
import matplotlib.pyplot as plt
import random

file_path = "C:/Users/StrataScratch/facebook_combined.txt/facebook_combined.txt"
G = nx.read_edgelist(file_path, create_using=nx.Graph(), nodetype=int)

most_connected_node = max(G.degree, key=lambda x: x[1])[0]

ego_graph = nx.ego_graph(G, most_connected_node, radius=1)

neighbors = list(ego_graph.neighbors(most_connected_node))
sampled_neighbors = random.sample(neighbors, min(10, len(neighbors)))  # Display at most 10 neighbors
simplified_graph = G.subgraph([most_connected_node] + sampled_neighbors)

plt.figure(figsize=(8, 8))
pos = nx.spring_layout(simplified_graph)
nx.draw(
    simplified_graph, pos,
    with_labels=True,
    node_size=100,
    node_color="skyblue",
    edge_color="gray"
)
plt.title(f"Subgraph: Node {most_connected_node} and Sampled Neighbors")
plt.show()

Visualization example: Here’s a graph showing node 107 and sampled neighbors.

Data Visualization Technique of Network Graphs for Relationships

Conclusion

There you have it: use these data visualization techniques when you want to impress. Creating such visualizations involves using some fundamental Python data visualization libraries, but also some less common. The results are often very impressive, both aesthetically- and insight-wise.

Leave a Reply

Your email address will not be published. Required fields are marked *