Fundamentals 8 min read

Explore Four Innovative Python Charts to Elevate Your Data Visualizations

This article introduces four innovative Python chart types—Radar Chart, Treemap, Ternary Plot, and Joy Plot—explaining their concepts, typical applications such as performance evaluation and market analysis, and providing complete code examples to help data analysts create compelling visualizations.

Model Perspective
Model Perspective
Model Perspective
Explore Four Innovative Python Charts to Elevate Your Data Visualizations

Data visualization is a crucial method for analyzing and understanding data. It helps extract useful information from complex datasets and presents trends, patterns, and relationships intuitively. This article introduces four novel chart types—Radar Chart, Treemap, Ternary Plot, and Joy Plot—explaining their meanings, typical use cases, and providing practical Python code examples.

1. Radar Chart

Chart Meaning

A radar chart is used for comparing multivariate data. Each axis represents a variable, and the variables are connected by a polygon. Points closer to an axis’s tip indicate higher values for that variable, allowing comparison of multiple dimensions across entities.

Practical Applications

Radar charts are commonly used for performance evaluation, market analysis, and product comparison, such as comparing a company’s products against competitors across price, quality, performance, user satisfaction, and market share.

<code>import matplotlib.pyplot as plt
import numpy as np

# Sample data
labels = ['价格', '质量', '性能', '用户满意度', '市场份额']
data = [85, 90, 75, 80, 70]  # Product A
data2 = [70, 88, 78, 85, 90]  # Product B

angles = np.linspace(0, 2 * np.pi, len(labels), endpoint=False).tolist()
# Close the polygon
data += data[:1]
data2 += data2[:1]
angles += angles[:1]

fig, ax = plt.subplots(figsize=(6, 6), subplot_kw=dict(polar=True))
ax.plot(angles, data, color='blue', linewidth=2, label='产品A')
ax.fill(angles, data, color='blue', alpha=0.25)
ax.plot(angles, data2, color='red', linewidth=2, label='产品B')
ax.fill(angles, data2, color='red', alpha=0.25)
ax.set_xticks(angles[:-1])
ax.set_xticklabels(labels)
ax.legend()
plt.show()
</code>

2. Treemap

Chart Meaning

A treemap visualizes hierarchical data by dividing the display area into nested rectangles, where each rectangle’s size is proportional to its data value. Colors and labels can represent additional attributes.

Practical Applications

Treemaps are widely used to display resource allocation, financial data, and sales figures, such as showing the sales contribution of different product lines within a company.

<code>import matplotlib.pyplot as plt
import squarify

# Sample data
labels = ['产品A', '产品B', '产品C', '产品D', '产品E']
sizes = [500, 300, 400, 200, 100]

squarify.plot(sizes=sizes, label=labels, alpha=0.7,
              color=['red', 'blue', 'green', 'purple', 'orange'])
plt.title('产品销售占比矩形树状图')
plt.axis('off')
plt.show()
</code>

3. Ternary Plot

Chart Meaning

A ternary plot visualizes the proportion relationship among three variables. Each point’s position is determined by the three component percentages, which sum to 100%.

Practical Applications

Ternary plots are common in chemistry, geology, and food science, for example, allowing chemical engineers to analyze how different component ratios affect product performance.

<code>import plotly.express as px
import pandas as pd

# Sample data
data = pd.DataFrame({
    '成分A': [30, 20, 40, 50],
    '成分B': [40, 50, 30, 20],
    '成分C': [30, 30, 30, 30],
    '样本': ['样本1', '样本2', '样本3', '样本4']
})

fig = px.scatter_ternary(data, a='成分A', b='成分B', c='成分C',
                         color='样本',
                         title='成分混合比例三元相图')
fig.show()
</code>

4. Joy Plot

Chart Meaning

A joy plot (also called a ridge plot) displays multiple overlapping density distribution curves, helping to compare the distribution characteristics of different groups within a single figure.

Practical Applications

Joy plots are often used in social sciences and market analysis, such as examining purchasing behavior across age groups or income distribution across regions.

<code>import numpy as np
import pandas as pd
import joypy
from matplotlib import pyplot as plt

# Sample data
df = pd.DataFrame({
    '年龄段': ['18-25', '26-35', '36-45'] * 100,
    '收入': np.random.normal(50000, 5000, 300)
})

fig, axes = joypy.joyplot(df, by='年龄段', column='收入',
                         figsize=(10, 6), color='lightblue')
plt.title('不同年龄段收入分布的峰峦图')
plt.xlabel('收入 (元)')
plt.show()
</code>

The four chart types presented—Radar Chart, Treemap, Ternary Plot, and Joy Plot—provide powerful ways to make data more intuitive and enhance reports and presentations. Mastering these visualization techniques enables data analysts and researchers to convey information more efficiently and support data‑driven decision making.

Pythondata visualizationRadar CharttreemapJoy PlotTernary Plot
Model Perspective
Written by

Model Perspective

Insights, knowledge, and enjoyment from a mathematical modeling researcher and educator. Hosted by Haihua Wang, a modeling instructor and author of "Clever Use of Chat for Mathematical Modeling", "Modeling: The Mathematics of Thinking", "Mathematical Modeling Practice: A Hands‑On Guide to Competitions", and co‑author of "Mathematical Modeling: Teaching Design and Cases".

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.