Matplotlib Best Practices Expert guidelines for Matplotlib development, focusing on data visualization, plotting, and creating publication-quality figures. Code Style and Structure - Write concise, technical Python code with accurate Matplotlib examples - Create informative and visually appealing plots with proper labels, titles, and legends - Use the object-oriented API for complex figures, pyplot for quick plots - Follow PEP 8 style guidelines - Consider color-blindness accessibility in all visualizations API Approaches Object-Oriented Interface (Recommended) - Use for explicit control - Pr…

`\n- Set font family for consistency\n- Adjust font sizes for readability at intended display size\n\n## Saving and Exporting\n\n### File Formats\n\n- Use vector formats (PDF, SVG, EPS) for publications\n- Use PNG for web and presentations with transparency\n- Use JPEG only for photographs (lossy compression)\n\n### Export Settings\n\n- Use `bbox_inches='tight'` to remove excess whitespace\n- Set `facecolor` for background color\n- Specify `dpi` appropriate for use case\n- Use `transparent=True` for overlays\n\n## Performance Optimization\n\n- Use `rasterized=True` for scatter plots with many points\n- Consider downsampling data for visualization\n- Close figures with `plt.close()` after saving\n- Use `plt.close('all')` in loops creating many figures\n\n## Key Conventions\n\n- Import as `import matplotlib.pyplot as plt`\n- Use object-oriented API for production code\n- Always label axes and include units\n- Test visualizations at intended display size\n- Consider accessibility in color choices","attachment_filenames":[],"attachments":[],"content_json":{"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"text":"Matplotlib Best Practices","type":"text"}]},{"type":"paragraph","content":[{"text":"Expert guidelines for Matplotlib development, focusing on data visualization, plotting, and creating publication-quality figures.","type":"text"}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Code Style and Structure","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Write concise, technical Python code with accurate Matplotlib examples","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Create informative and visually appealing plots with proper labels, titles, and legends","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use the object-oriented API for complex figures, pyplot for quick plots","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Follow PEP 8 style guidelines","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Consider color-blindness accessibility in all visualizations","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"API Approaches","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Object-Oriented Interface (Recommended)","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"fig, ax = plt.subplots()","type":"text","marks":[{"type":"code_inline"}]},{"text":" for explicit control","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Preferred for complex figures and production code","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Methods are called on axes objects: ","type":"text"},{"text":"ax.plot()","type":"text","marks":[{"type":"code_inline"}]},{"text":", ","type":"text"},{"text":"ax.set_xlabel()","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Enables multiple subplots and fine-grained customization","type":"text"}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Pyplot Interface","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"plt.plot()","type":"text","marks":[{"type":"code_inline"}]},{"text":", ","type":"text"},{"text":"plt.xlabel()","type":"text","marks":[{"type":"code_inline"}]},{"text":" for quick, interactive plots","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Suitable for Jupyter notebooks and exploration","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"%matplotlib inline","type":"text","marks":[{"type":"code_inline"}]},{"text":" in Jupyter notebooks","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Creating Effective Visualizations","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Plot Types and Selection","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Line plots (","type":"text"},{"text":"ax.plot()","type":"text","marks":[{"type":"code_inline"}]},{"text":") for continuous data and trends","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Scatter plots (","type":"text"},{"text":"ax.scatter()","type":"text","marks":[{"type":"code_inline"}]},{"text":") for relationship between variables","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Bar plots (","type":"text"},{"text":"ax.bar()","type":"text","marks":[{"type":"code_inline"}]},{"text":", ","type":"text"},{"text":"ax.barh()","type":"text","marks":[{"type":"code_inline"}]},{"text":") for categorical comparisons","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Histograms (","type":"text"},{"text":"ax.hist()","type":"text","marks":[{"type":"code_inline"}]},{"text":") for distributions","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Box plots (","type":"text"},{"text":"ax.boxplot()","type":"text","marks":[{"type":"code_inline"}]},{"text":") for statistical summaries","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Heatmaps (","type":"text"},{"text":"ax.imshow()","type":"text","marks":[{"type":"code_inline"}]},{"text":", ","type":"text"},{"text":"ax.pcolormesh()","type":"text","marks":[{"type":"code_inline"}]},{"text":") for 2D data","type":"text"}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Labels and Annotations","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Always include axis labels with units","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use descriptive titles that convey the message","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Add legends when multiple series are present","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use annotations (","type":"text"},{"text":"ax.annotate()","type":"text","marks":[{"type":"code_inline"}]},{"text":") to highlight key points","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Include data source attribution when appropriate","type":"text"}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Color and Style","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use colorblind-friendly palettes (e.g., 'viridis', 'plasma', 'cividis')","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Avoid red-green combinations for accessibility","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use consistent colors for the same categories across figures","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use appropriate colormaps for data type:","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Sequential: 'viridis', 'plasma' for continuous data","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Diverging: 'RdBu', 'coolwarm' for data with meaningful center","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Qualitative: 'Set1', 'tab10' for categorical data","type":"text"}]}]}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Figure Layout and Composition","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Subplots","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"plt.subplots(nrows, ncols)","type":"text","marks":[{"type":"code_inline"}]},{"text":" for grid layouts","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"gridspec","type":"text","marks":[{"type":"code_inline"}]},{"text":" for complex, non-uniform layouts","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Share axes with ","type":"text"},{"text":"sharex=True","type":"text","marks":[{"type":"code_inline"}]},{"text":", ","type":"text"},{"text":"sharey=True","type":"text","marks":[{"type":"code_inline"}]},{"text":" for comparison","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"constrained_layout=True","type":"text","marks":[{"type":"code_inline"}]},{"text":" or ","type":"text"},{"text":"tight_layout()","type":"text","marks":[{"type":"code_inline"}]},{"text":" to prevent overlap","type":"text"}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Figure Size and Resolution","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Set figure size explicitly: ","type":"text"},{"text":"figsize=(width, height)","type":"text","marks":[{"type":"code_inline"}]},{"text":" in inches","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use appropriate DPI for intended output (72 screen, 300+ print)","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Standard sizes: (10, 6) for presentations, (8, 6) for papers","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Customization","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Style Sheets","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use built-in styles: ","type":"text"},{"text":"plt.style.use('seaborn-v0_8')","type":"text","marks":[{"type":"code_inline"}]},{"text":", ","type":"text"},{"text":"'ggplot'","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Create custom style files for consistent branding","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Combine styles: ","type":"text"},{"text":"plt.style.use(['seaborn-v0_8', 'custom.mplstyle'])","type":"text","marks":[{"type":"code_inline"}]}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Text and Fonts","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use LaTeX for mathematical notation: ","type":"text"},{"text":"r'$\\alpha = \\frac{1}{2}

Matplotlib Best Practices Expert guidelines for Matplotlib development, focusing on data visualization, plotting, and creating publication-quality figures. Code Style and Structure - Write concise, technical Python code with accurate Matplotlib examples - Create informative and visually appealing plots with proper labels, titles, and legends - Use the object-oriented API for complex figures, pyplot for quick plots - Follow PEP 8 style guidelines - Consider color-blindness accessibility in all visualizations API Approaches Object-Oriented Interface (Recommended) - Use for explicit control - Pr…

","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Set font family for consistency","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Adjust font sizes for readability at intended display size","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Saving and Exporting","type":"text"}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"File Formats","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use vector formats (PDF, SVG, EPS) for publications","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use PNG for web and presentations with transparency","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use JPEG only for photographs (lossy compression)","type":"text"}]}]}]},{"type":"heading","attrs":{"level":3},"content":[{"text":"Export Settings","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"bbox_inches='tight'","type":"text","marks":[{"type":"code_inline"}]},{"text":" to remove excess whitespace","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Set ","type":"text"},{"text":"facecolor","type":"text","marks":[{"type":"code_inline"}]},{"text":" for background color","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Specify ","type":"text"},{"text":"dpi","type":"text","marks":[{"type":"code_inline"}]},{"text":" appropriate for use case","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"transparent=True","type":"text","marks":[{"type":"code_inline"}]},{"text":" for overlays","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Performance Optimization","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"rasterized=True","type":"text","marks":[{"type":"code_inline"}]},{"text":" for scatter plots with many points","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Consider downsampling data for visualization","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Close figures with ","type":"text"},{"text":"plt.close()","type":"text","marks":[{"type":"code_inline"}]},{"text":" after saving","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use ","type":"text"},{"text":"plt.close('all')","type":"text","marks":[{"type":"code_inline"}]},{"text":" in loops creating many figures","type":"text"}]}]}]},{"type":"heading","attrs":{"level":2},"content":[{"text":"Key Conventions","type":"text"}]},{"type":"bullet_list","content":[{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Import as ","type":"text"},{"text":"import matplotlib.pyplot as plt","type":"text","marks":[{"type":"code_inline"}]}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Use object-oriented API for production code","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Always label axes and include units","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Test visualizations at intended display size","type":"text"}]}]},{"type":"list_item","content":[{"type":"paragraph","content":[{"text":"Consider accessibility in color choices","type":"text"}]}]}]}]},"metadata":{"date":"2026-11-02","name":"matplotlib-best-practices","author":"@skillopedia","source":{"stars":291,"repo_name":"skills","origin_url":"https://github.com/Mindrally/skills/blob/HEAD/matplotlib-best-practices/SKILL.md","repo_owner":"Mindrally","body_sha256":"a8e1cd621d12883f15ead33225e6c2bdb7663ed9c274514915bf74fe93e624ff","cluster_key":"efbef4dbedded065f06184012b768bd909ec13b512f224db184d5339a18a2c19","clean_bundle":{"format":"clean-skill-bundle-v1","source":"Mindrally/skills/matplotlib-best-practices/SKILL.md","text_bytes":0,"source_commit":"7682ca77710e0971eab4e0ae5dddfa281aea0ba5","skills_sh_rank":12633,"attachment_count":0,"text_attachments":0,"attachment_storage":"skill_attachments","binary_attachments":0},"cluster_size":1,"skill_md_path":"matplotlib-best-practices/SKILL.md","import_metadata":{"date":"2026-11-02","author":"@skillopedia","version":"v1","category":"data-analytics","category_label":"Data"},"exact_dupes_collapsed_into_this":0},"version":"v1","category":"data-analytics","metadata":{"source":"https://github.com/Mindrally/skills","maintainer":"Mindrally"},"import_tag":"skills-sh-top20k-2026-11","description":"Best practices for Matplotlib data visualization, plotting, and creating publication-quality figures in Python"}},"renderedAt":1793665958918}

Matplotlib Best Practices Expert guidelines for Matplotlib development, focusing on data visualization, plotting, and creating publication-quality figures. Code Style and Structure - Write concise, technical Python code with accurate Matplotlib examples - Create informative and visually appealing plots with proper labels, titles, and legends - Use the object-oriented API for complex figures, pyplot for quick plots - Follow PEP 8 style guidelines - Consider color-blindness accessibility in all visualizations API Approaches Object-Oriented Interface (Recommended) - Use for explicit control - Pr…