--- name: data-viz description: Create data visualizations, charts, and graphs using Python matplotlib, seaborn, and plotly --- # Data Visualization Skill ## Capabilities Create publication-quality charts and visualizations using Python libraries. ## Chart Types ### Bar Charts ```python import matplotlib.pyplot as plt import seaborn as sns # Data categories = ['A', 'B', 'C'] values = [10, 20, 15] # Create plt.figure(figsize=(10, 6)) sns.barplot(x=categories, y=values, palette='viridis') plt.title('Bar Chart Title', fontsize=14, fontweight='bold') plt.xlabel('Categories') plt.ylabel('Values') plt.tight_layout() plt.savefig('/tmp/bar_chart.png', dpi=300) ``` ### Line Charts ```python import pandas as pd # Time series data dates = pd.date_range('2024-01', periods=12, freq='M') values = [100, 105, 110, 108, 115, 120, 118, 125, 130, 128, 135, 140] plt.figure(figsize=(12, 6)) plt.plot(dates, values, marker='o', linewidth=2, markersize=8) plt.title('Monthly Trend') plt.xlabel('Month') plt.ylabel('Value') plt.grid(True, alpha=0.3) plt.xticks(rotation=45) plt.tight_layout() plt.savefig('/tmp/line_chart.png', dpi=300) ``` ### Pie Charts ```python labels = ['Category A', 'Category B', 'Category C'] sizes = [30, 45, 25] colors = ['#ff9999', '#66b3ff', '#99ff99'] plt.figure(figsize=(8, 8)) plt.pie(sizes, labels=labels, colors=colors, autopct='%1.1f%%', startangle=90, textprops={'fontsize': 12}) plt.title('Distribution', fontsize=14, fontweight='bold') plt.axis('equal') plt.savefig('/tmp/pie_chart.png', dpi=300) ``` ### Heatmaps ```python import numpy as np # Correlation matrix data = np.random.rand(5, 5) labels = ['A', 'B', 'C', 'D', 'E'] plt.figure(figsize=(10, 8)) sns.heatmap(data, annot=True, fmt='.2f', xticklabels=labels, yticklabels=labels, cmap='coolwarm', center=0) plt.title('Correlation Heatmap') plt.tight_layout() plt.savefig('/tmp/heatmap.png', dpi=300) ``` ## Styling Best Practices - Use consistent color schemes - Add titles and labels - Include legends when needed - Use appropriate chart types for data - 300 DPI for high quality - Transparent backgrounds for flexibility ## Output Always save to `/tmp/` with descriptive filenames.