Slope Chart
Chart overview
A slope chart (or slopegraph) places two vertical axes side by side representing two time points or conditions, connects each subject or group with a line, and lets the eye immediately read upward or downward trends and relative ranking changes.
Key points
- Scientists use it to compare paired pre-post measurements or treatment versus control outcomes.
- It is more space-efficient and perceptually clearer than a grouped bar chart for exactly two conditions.
Python Tutorial
How to create a slope chart in Python
Use the full tutorial for implementation details, troubleshooting, and chart variations in matplotlib, seaborn, and plotly.
How to Create a Bar Chart in PythonExample Visualization

Create This Chart Now
Generate publication-ready slope charts with AI in seconds. No coding required – just describe your data and let AI do the work.
View example prompt
"Create a slope chart from my data. Draw two vertical axes for the two conditions, connect each item with a labelled line, colour lines by increase or decrease, and format as a clean publication-quality figure with a minimal grid."
How to create this chart in 30 seconds
Upload Data
Drag & drop your Excel or CSV file. Plotivy securely processes it in your browser.
AI Generation
Our AI analyzes your data and generates the Slope Chart code automatically.
Customize & Export
Tweak the design with natural language, then export as high-res PNG, SVG or PDF.
Newsletter
Get one weekly tip for better slope charts
Join researchers receiving concise Python plotting techniques to improve chart clarity and reduce revision cycles.
Python Code Example
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
data = {'Category': ['A', 'B', 'C', 'D'], '2020': [10, 20, 15, 30], '2024': [25, 15, 30, 20]}
df = pd.DataFrame(data)
plt.figure(figsize=(8, 6))
for i in range(len(df)):
plt.plot([0, 1], [df['2020'][i], df['2024'][i]], marker='o', markersize=8, linewidth=2, label=df['Category'][i])
plt.text(-0.05, df['2020'][i], f"{df['Category'][i]} ({df['2020'][i]})", ha='right', va='center', fontweight='bold')
plt.text(1.05, df['2024'][i], f"({df['2024'][i]})", ha='left', va='center', fontweight='bold')
plt.xlim(-0.5, 1.5)
plt.xticks([0, 1], ['2020', '2024'], fontsize=12, fontweight='bold')
plt.yticks([])
plt.axvline(0, color='gray', linewidth=0.5)
plt.axvline(1, color='gray', linewidth=0.5)
plt.box(False)
plt.title('Slope Chart: Evolution 2020-2024', fontsize=14, fontweight='bold', pad=20)
plt.tight_layout()
plt.savefig('plotivy-slope-chart.png', dpi=150)
print("Slope chart generated successfully.")
Opens the Analyze page with this code pre-loaded and ready to execute
Console Output
Slope chart generated successfully.
Common Use Cases
- 1Comparing pre-treatment and post-treatment biomarker values across patient groups
- 2Showing ranking changes between two experimental sessions in cognitive testing
- 3Visualising gene expression fold-change between two conditions for selected genes
- 4Displaying country-level metric changes between two survey waves
Pro Tips
Label both endpoints of each line directly on the plot to avoid a legend
Colour lines by direction (e.g. green for increase, red for decrease) for instant readability
Sort items by the left-axis value to prevent excessive line crossings
Use consistent y-axis scales and clearly label each vertical axis with units
Long-tail keyword opportunities
High-intent chart variations
Library comparison for this chart
matplotlib
Best when you need full control over axis formatting, annotation placement, and journal-specific styling for slope-chart.
numpy
Useful in specialized workflows that complement core Python plotting libraries for slope-chart analysis tasks.
Scientific Chart Selection Cheat Sheet
Not sure whether to use a Violin Plot, Box Plot, or Ridge Plot? Download our single-page reference mapping the most-used scientific chart types, exactly when to use them, and the core Matplotlib/Seaborn functions.