visualize-data
Create data visualizations from analyzed CSV data
Source facts
- Repository
- AgiFlow/token-usage-metrics
- Last source activity
- November 16, 2025 at 08:55
- Detected SKILL.md language
- English
- Stars
- 1
- Forks
- 0
Install options
The review-first prompt is selected by default. You can switch to a direct command or download a local copy.
Review the source files
Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.
Showing SKILL.md
SKILL.md
Source instructions · Read-only preview- name
- visualize-data
- description
- Create data visualizations from analyzed CSV data
# Data Visualization Skill
You are helping create visualizations from analyzed data. Follow these steps:
## 1. Setup Environment and Visualization Library
**IMPORTANT: Always use a Python virtual environment for this task.**
Before running any Python scripts, set up a virtual environment:
```bash
# Create virtual environment (if not already created)
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate # On macOS/Linux
# OR
venv\Scripts\activate # On Windows
# Install required packages
pip install pandas matplotlib seaborn numpy
```
Use matplotlib and seaborn (Python) for creating charts:
```python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
```
## 2. Required Visualizations
### Bar Chart: Average Salary by Department
- X-axis: Department names
- Y-axis: Average salary
- Add value labels on top of bars
- Use appropriate colors
- Save as: `output/salary_by_dept.png`
### Bar Chart: Average Performance Score by Department
- X-axis: Department names
- Y-axis: Average performance score (0-5 scale)
- Add value labels on top of bars
- Use different color scheme
- Save as: `output/performance_by_dept.png`
### Scatter Plot: Experience vs. Salary
- X-axis: Years of experience
- Y-axis: Salary
- Add trend line (linear regression)
- Show correlation coefficient in title
- Color points by department (optional)
- Save as: `output/experience_vs_salary.png`
### Pie Chart: Employee Distribution by Location
- Show percentage for each location
- Use distinct colors
- Add labels with counts and percentages
- Save as: `output/location_distribution.png`
## 3. Visualization Best Practices
- Set figure size appropriately (e.g., 10x6 inches)
- Use clear, readable fonts
- Add titles, axis labels, and legends
- Use color palettes that are colorblind-friendly
- Save with high DPI (at least 300)
- Close figures after saving to free memory
## 4. Complete Script Template
```python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
import os
# Set style
sns.set_style("whitegrid")
plt.rcParams['figure.figsize'] = (10, 6)
# Read the CSV data
df = pd.read_csv('../shared/sample-data.csv')
# Create output directory
os.makedirs('output', exist_ok=True)
# 1. Bar Chart: Average Salary by Department
plt.figure(figsize=(10, 6))
dept_salary = df.groupby('department')['salary'].mean().sort_values(ascending=False)
bars = plt.bar(dept_salary.index, dept_salary.values, color='steelblue', alpha=0.8)
plt.title('Average Salary by Department', fontsize=16, fontweight='bold')
plt.xlabel('Department', fontsize=12)
plt.ylabel('Average Salary ($)', fontsize=12)
plt.xticks(rotation=45, ha='right')
# Add value labels on bars
for bar in bars:
height = bar.get_height()
plt.text(bar.get_x() + bar.get_width()/2., height,
f'${height:,.0f}',
ha='center', va='bottom', fontsize=10)
plt.tight_layout()
plt.savefig('output/salary_by_dept.png', dpi=300, bbox_inches='tight')
plt.close()
print("✓ Created salary_by_dept.png")
# 2. Bar Chart: Average Performance Score by Department
plt.figure(figsize=(10, 6))
dept_perf = df.groupby('department')['performance_score'].mean().sort_values(ascending=False)
bars = plt.bar(dept_perf.index, dept_perf.values, color='coral', alpha=0.8)
plt.title('Average Performance Score by Department', fontsize=16, fontweight='bold')
plt.xlabel('Department', fontsize=12)
plt.ylabel('Average Performance Score', fontsize=12)
plt.ylim(0, 5)
plt.xticks(rotation=45, ha='right')
# Add value labels on bars
for bar in bars:
height = bar.get_height()
plt.text(bar.get_x() + bar.get_width()/2., height,
f'{height:.2f}',
ha='center', va='bottom', fontsize=10)
plt.tight_layout()
plt.savefig('output/performance_by_dept.png', dpi=300, bbox_inches='tight')
plt.close()
print("✓ Created performance_by_dept.png")
# 3. Scatter Plot: Experience vs. Salary
plt.figure(figsize=(10, 6))
correlation = df['years_experience'].corr(df['salary'])
# Create scatter plot with different colors for departments
for dept in df['department'].unique():
dept_data = df[df['department'] == dept]
plt.scatter(dept_data['years_experience'], dept_data['salary'],
label=dept, alpha=0.6, s=100)
# Add trend line
z = np.polyfit(df['years_experience'], df['salary'], 1)
p = np.poly1d(z)
plt.plot(df['years_experience'].sort_values(),
p(df['years_experience'].sort_values()),
"k--", alpha=0.5, linewidth=2, label='Trend Line')
plt.title(f'Years of Experience vs. Salary (Correlation: {correlation:.3f})',
fontsize=16, fontweight='bold')
plt.xlabel('Years of Experience', fontsize=12)
plt.ylabel('Salary ($)', fontsize=12)
plt.legend()
plt.grid(True, alpha=0.3)
plt.tight_layout()
plt.savefig('output/experience_vs_salary.png', dpi=300, bbox_inches='tight')
plt.close()
print("✓ Created experience_vs_salary.png")
# 4. Pie Chart: Employee Distribution by Location
plt.figure(figsize=(10, 8))
location_counts = df['location'].value_counts()
colors = sns.color_palette('Set3', len(location_counts))
plt.pie(location_counts.values, labels=location_counts.index, autopct='%1.1f%%',
colors=colors, startangle=90, textprops={'fontsize': 11})
plt.title('Employee Distribution by Location', fontsize=16, fontweight='bold', pad=20)
plt.axis('equal')
plt.tight_layout()
plt.savefig('output/location_distribution.png', dpi=300, bbox_inches='tight')
plt.close()
print("✓ Created location_distribution.png")
print("\n✓ All visualizations created successfully in output/ directory")
```
## 5. Dependencies Required
Ensure these packages are installed:
```bash
pip install pandas matplotlib seaborn numpy
```
## 6. Output Verification
After running the script, verify:
- All 4 PNG files are created in `output/` directory
- Images are high quality (300 DPI)
- Charts are readable and properly labeled
- No warnings or errors in execution
View on GitHub