# mplstyles-seaborn
[](https://python.org)
[](LICENSE)
[](https://matplotlib.org)
[](https://github.com/monodera/mplstyles-seaborn/actions)
[](https://codecov.io/gh/monodera/mplstyles-seaborn)
[](https://github.com/monodera/mplstyles-seaborn/commits)
[](https://github.com/monodera/mplstyles-seaborn/issues)
[](#api-reference)
[](#available-options)
Matplotlib style sheets based on seaborn v0.8 themes with combinable palettes and contexts.
## Overview
While matplotlib includes built-in seaborn v0.8 style sheets, they offer only a limited set of predefined combinations. This package extends matplotlib's seaborn styling without requiring seaborn as a dependency, providing all 120 possible combinations of seaborn's styles, color palettes, and contexts.
## Features
- **Zero seaborn dependency**: Use seaborn-style plots with pure matplotlib
- **Complete coverage**: All 120 combinations of seaborn v0.8 styles, palettes, and contexts
- **Easy integration**: Styles automatically registered with matplotlib on import
- **Multiple usage methods**: Convenience functions or direct matplotlib integration
- **Type hints**: Full type annotation support

## Example Galleries
For comprehensive visual examples, see our **[📸 Example Galleries](examples/)**:
- **[Basic Usage Gallery](examples/basic_usage_gallery.md)** - Fundamental usage patterns and plot types
- **[Style Comparison Gallery](examples/style_comparison_gallery.md)** - All 120 style combinations visualized
- **[Comprehensive Demo Gallery](examples/comprehensive_demo_gallery.md)** - Advanced plot types and publication-ready figures
## Installation
Install from PyPI:
```bash
pip install mplstyles-seaborn
```
Or with uv:
```bash
uv add mplstyles-seaborn
```
### Development Installation
For development, install directly from GitHub:
```bash
pip install git+https://github.com/monodera/mplstyles-seaborn.git
```
Or with uv:
```bash
uv add git+https://github.com/monodera/mplstyles-seaborn.git
```
## Quick Start
```python
import matplotlib.pyplot as plt
import mplstyles_seaborn
import numpy as np
# Generate sample data
x = np.linspace(0, 10, 100)
y = np.sin(x)
# Method 1: Use convenience function
mplstyles_seaborn.use_style('whitegrid', 'colorblind', 'talk')
plt.figure(figsize=(10, 6))
plt.plot(x, y, label='sin(x)')
plt.title('Example Plot')
plt.legend()
plt.show()
```
## Available Options
### Styles (5 options)
- `darkgrid` - Dark grid background
- `whitegrid` - White grid background
- `dark` - Dark background, no grid
- `white` - White background, no grid
- `ticks` - White background with ticks
### Palettes (6 options)
- `dark` - Deep, saturated colors
- `colorblind` - Colorblind-friendly palette
- `muted` - Muted, subdued colors
- `bright` - Bright, vibrant colors
- `pastel` - Light, pastel colors
- `deep` - Dark, deep colors
### Contexts (4 options)
- `paper` - Smallest elements, for papers/publications
- `notebook` - Default size, for notebooks
- `talk` - Larger elements, for presentations
- `poster` - Largest elements, for posters
## Usage Methods
### 1. Convenience Function
```python
import mplstyles_seaborn
# Use all three parameters
mplstyles_seaborn.use_style('whitegrid', 'colorblind', 'talk')
# Use defaults for some parameters (defaults: darkgrid, dark, notebook)
mplstyles_seaborn.use_style(palette='colorblind', context='talk')
```
### 2. Direct Matplotlib
```python
import matplotlib.pyplot as plt
# Styles are automatically registered on import
plt.style.use('seaborn-v0_8-whitegrid-colorblind-talk')
```
### 3. List Available Styles
```python
import mplstyles_seaborn
# See all 120 available style combinations
styles = mplstyles_seaborn.list_available_styles()
print(f"Available styles: {len(styles)}")
# Print first few styles
for style in styles[:5]:
print(style)
```
Run the examples with:
```bash
# Basic usage examples
uv run python examples/basic_usage.py
# Generate all 120 style combination comparisons
uv run python examples/style_comparison.py
# Comprehensive demonstration with 7 different plot types
uv run python examples/comprehensive_demo.py
```
### Basic Line Plot
```python
import matplotlib.pyplot as plt
import numpy as np
import mplstyles_seaborn
# Apply style
mplstyles_seaborn.use_style('whitegrid', 'colorblind', 'talk')
# Create plot
x = np.linspace(0, 10, 100)
fig, ax = plt.subplots(figsize=(10, 6))
ax.plot(x, np.sin(x), label='sin(x)', linewidth=2)
ax.plot(x, np.cos(x), label='cos(x)', linewidth=2)
ax.plot(x, np.sin(x + np.pi/4), label='sin(x + pi/4)', linewidth=2)
ax.set_title('Trigonometric Functions')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.legend()
plt.tight_layout()
plt.show()
```
### Scatter Plot
```python
import matplotlib.pyplot as plt
import numpy as np
import mplstyles_seaborn
# Apply dark theme with muted palette
mplstyles_seaborn.use_style('dark', 'muted', 'notebook')
# Generate data
np.random.seed(42)
x = np.random.randn(200)
y = np.random.randn(200)
# Create scatter plot
fig, ax = plt.subplots(figsize=(8, 6))
ax.scatter(x, y, alpha=0.7, s=60)
ax.set_title('Random Scatter Plot')
ax.set_xlabel('X values')
ax.set_ylabel('Y values')
plt.tight_layout()
plt.show()
```
## Font Configuration
The package includes optimized font settings:
1. **Source Sans 3** (if available)
2. **Arial** (fallback)
3. **DejaVu Sans** (further fallback)
4. System fonts
Font family is automatically set to `sans-serif` for consistent appearance.
## API Reference
### Functions
#### `use_style(style='darkgrid', palette='dark', context='notebook')`
Apply a seaborn-v0.8 style with specified parameters.
**Parameters:**
- `style` (str): Style type - 'darkgrid', 'whitegrid', 'dark', 'white', 'ticks'
- `palette` (str): Color palette - 'dark', 'colorblind', 'muted', 'bright', 'pastel', 'deep'
- `context` (str): Context scaling - 'paper', 'notebook', 'talk', 'poster'
#### `list_available_styles()`
Returns a sorted list of all 120 available style names.
**Returns:**
- `list[str]`: List of style names
#### `register_styles()`
Register all styles with matplotlib (called automatically on import).
### Constants
- `STYLES`: List of available style types
- `PALETTES`: List of available color palettes
- `CONTEXTS`: List of available contexts
## Development
### Requirements
- Python >=3.11
- matplotlib >=3.5
- seaborn >=0.11 (for development/generation only)
### Setup
```bash
git clone https://github.com/monodera/mplstyles-seaborn.git
cd mplstyles-seaborn
uv sync
```
### Testing
This project includes comprehensive tests covering:
- Unit tests for all API functions
- Integration tests with matplotlib
- Validation tests for all 120 style files
- Error handling and edge cases
- Performance benchmarks
#### Running Tests
```bash
# Install test dependencies
uv sync --extra test
# Run all tests
uv run pytest
# Run tests with coverage
uv run pytest --cov=src/mplstyles_seaborn --cov-report=term-missing
# Run specific test categories
uv run pytest tests/test_api.py # API function tests
uv run pytest tests/test_integration.py # Matplotlib integration tests
uv run pytest tests/test_styles.py # Style file validation tests
uv run pytest tests/test_errors.py # Error handling tests
# Run performance tests (marked as slow)
uv run pytest tests/test_performance.py -m "not slow" # Fast performance tests
uv run pytest tests/test_performance.py # All performance tests
# Run with verbose output
uv run pytest -v
```
#### Manual Testing
```bash
# Test package import and basic functionality
uv run python -c "import mplstyles_seaborn; print(len(mplstyles_seaborn.list_available_styles()))"
# Test specific style application
uv run python -c "import matplotlib.pyplot as plt; plt.style.use('seaborn-v0_8-whitegrid-colorblind-talk')"
# Run example scripts
uv run python examples/basic_usage.py
uv run python examples/style_comparison.py
uv run python examples/comprehensive_demo.py
```
### Regenerating Styles
```bash
# Generate and fix all 120 style files in one command (recommended)
uv run python scripts/build_styles.py
# Alternative: Generate only (for development/testing)
uv run python scripts/build_styles.py --generate-only
# Alternative: Fix existing files only
uv run python scripts/build_styles.py --fix-only
```
## License
This project is licensed under the MIT License.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## Development Support
This project was primarily developed using [Claude Code](https://claude.ai/code), Anthropic's AI-powered coding assistant.
## Related Projects
- [seaborn](https://seaborn.pydata.org/) - Statistical data visualization library
- [matplotlib](https://matplotlib.org/) - Python plotting library
Raw data
{
"_id": null,
"home_page": null,
"name": "mplstyles-seaborn",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "matplotlib, seaborn, plotting, visualization, styles",
"author": null,
"author_email": "Masato Onodera <masato.onodera@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/ed/6b/278de3eff092eb7c2575f8aea5c3c3a8c5ec8c0a19ca0be45954e2cc65e9/mplstyles_seaborn-0.2.5.tar.gz",
"platform": null,
"description": "# mplstyles-seaborn\n\n[](https://python.org)\n[](LICENSE)\n[](https://matplotlib.org)\n[](https://github.com/monodera/mplstyles-seaborn/actions)\n[](https://codecov.io/gh/monodera/mplstyles-seaborn)\n[](https://github.com/monodera/mplstyles-seaborn/commits)\n[](https://github.com/monodera/mplstyles-seaborn/issues)\n[](#api-reference)\n[](#available-options)\n\nMatplotlib style sheets based on seaborn v0.8 themes with combinable palettes and contexts.\n\n## Overview\n\nWhile matplotlib includes built-in seaborn v0.8 style sheets, they offer only a limited set of predefined combinations. This package extends matplotlib's seaborn styling without requiring seaborn as a dependency, providing all 120 possible combinations of seaborn's styles, color palettes, and contexts.\n\n## Features\n\n- **Zero seaborn dependency**: Use seaborn-style plots with pure matplotlib\n- **Complete coverage**: All 120 combinations of seaborn v0.8 styles, palettes, and contexts\n- **Easy integration**: Styles automatically registered with matplotlib on import\n- **Multiple usage methods**: Convenience functions or direct matplotlib integration\n- **Type hints**: Full type annotation support\n\n\n\n## Example Galleries\n\nFor comprehensive visual examples, see our **[\ud83d\udcf8 Example Galleries](examples/)**:\n\n- **[Basic Usage Gallery](examples/basic_usage_gallery.md)** - Fundamental usage patterns and plot types\n- **[Style Comparison Gallery](examples/style_comparison_gallery.md)** - All 120 style combinations visualized \n- **[Comprehensive Demo Gallery](examples/comprehensive_demo_gallery.md)** - Advanced plot types and publication-ready figures\n\n## Installation\n\nInstall from PyPI:\n\n```bash\npip install mplstyles-seaborn\n```\n\nOr with uv:\n\n```bash\nuv add mplstyles-seaborn\n```\n\n### Development Installation\n\nFor development, install directly from GitHub:\n\n```bash\npip install git+https://github.com/monodera/mplstyles-seaborn.git\n```\n\nOr with uv:\n\n```bash\nuv add git+https://github.com/monodera/mplstyles-seaborn.git\n```\n\n## Quick Start\n\n```python\nimport matplotlib.pyplot as plt\nimport mplstyles_seaborn\nimport numpy as np\n\n# Generate sample data\nx = np.linspace(0, 10, 100)\ny = np.sin(x)\n\n# Method 1: Use convenience function\nmplstyles_seaborn.use_style('whitegrid', 'colorblind', 'talk')\n\nplt.figure(figsize=(10, 6))\nplt.plot(x, y, label='sin(x)')\nplt.title('Example Plot')\nplt.legend()\nplt.show()\n```\n\n## Available Options\n\n### Styles (5 options)\n- `darkgrid` - Dark grid background\n- `whitegrid` - White grid background \n- `dark` - Dark background, no grid\n- `white` - White background, no grid\n- `ticks` - White background with ticks\n\n### Palettes (6 options)\n- `dark` - Deep, saturated colors\n- `colorblind` - Colorblind-friendly palette\n- `muted` - Muted, subdued colors\n- `bright` - Bright, vibrant colors\n- `pastel` - Light, pastel colors\n- `deep` - Dark, deep colors\n\n### Contexts (4 options)\n- `paper` - Smallest elements, for papers/publications\n- `notebook` - Default size, for notebooks\n- `talk` - Larger elements, for presentations\n- `poster` - Largest elements, for posters\n\n## Usage Methods\n\n### 1. Convenience Function\n\n```python\nimport mplstyles_seaborn\n\n# Use all three parameters\nmplstyles_seaborn.use_style('whitegrid', 'colorblind', 'talk')\n\n# Use defaults for some parameters (defaults: darkgrid, dark, notebook)\nmplstyles_seaborn.use_style(palette='colorblind', context='talk')\n```\n\n### 2. Direct Matplotlib\n\n```python\nimport matplotlib.pyplot as plt\n\n# Styles are automatically registered on import\nplt.style.use('seaborn-v0_8-whitegrid-colorblind-talk')\n```\n\n### 3. List Available Styles\n\n```python\nimport mplstyles_seaborn\n\n# See all 120 available style combinations\nstyles = mplstyles_seaborn.list_available_styles()\nprint(f\"Available styles: {len(styles)}\")\n\n# Print first few styles\nfor style in styles[:5]:\n print(style)\n```\n\nRun the examples with:\n\n```bash\n# Basic usage examples\nuv run python examples/basic_usage.py\n\n# Generate all 120 style combination comparisons \nuv run python examples/style_comparison.py\n\n# Comprehensive demonstration with 7 different plot types\nuv run python examples/comprehensive_demo.py\n```\n\n### Basic Line Plot\n\n```python\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport mplstyles_seaborn\n\n# Apply style\nmplstyles_seaborn.use_style('whitegrid', 'colorblind', 'talk')\n\n# Create plot\nx = np.linspace(0, 10, 100)\nfig, ax = plt.subplots(figsize=(10, 6))\n\nax.plot(x, np.sin(x), label='sin(x)', linewidth=2)\nax.plot(x, np.cos(x), label='cos(x)', linewidth=2)\nax.plot(x, np.sin(x + np.pi/4), label='sin(x + pi/4)', linewidth=2)\n\nax.set_title('Trigonometric Functions')\nax.set_xlabel('x')\nax.set_ylabel('y')\nax.legend()\n\nplt.tight_layout()\nplt.show()\n```\n\n### Scatter Plot\n\n```python\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport mplstyles_seaborn\n\n# Apply dark theme with muted palette\nmplstyles_seaborn.use_style('dark', 'muted', 'notebook')\n\n# Generate data\nnp.random.seed(42)\nx = np.random.randn(200)\ny = np.random.randn(200)\n\n# Create scatter plot\nfig, ax = plt.subplots(figsize=(8, 6))\nax.scatter(x, y, alpha=0.7, s=60)\nax.set_title('Random Scatter Plot')\nax.set_xlabel('X values')\nax.set_ylabel('Y values')\n\nplt.tight_layout()\nplt.show()\n```\n\n## Font Configuration\n\nThe package includes optimized font settings:\n\n1. **Source Sans 3** (if available)\n2. **Arial** (fallback)\n3. **DejaVu Sans** (further fallback)\n4. System fonts\n\nFont family is automatically set to `sans-serif` for consistent appearance.\n\n## API Reference\n\n### Functions\n\n#### `use_style(style='darkgrid', palette='dark', context='notebook')`\n\nApply a seaborn-v0.8 style with specified parameters.\n\n**Parameters:**\n- `style` (str): Style type - 'darkgrid', 'whitegrid', 'dark', 'white', 'ticks'\n- `palette` (str): Color palette - 'dark', 'colorblind', 'muted', 'bright', 'pastel', 'deep' \n- `context` (str): Context scaling - 'paper', 'notebook', 'talk', 'poster'\n\n#### `list_available_styles()`\n\nReturns a sorted list of all 120 available style names.\n\n**Returns:**\n- `list[str]`: List of style names\n\n#### `register_styles()`\n\nRegister all styles with matplotlib (called automatically on import).\n\n### Constants\n\n- `STYLES`: List of available style types\n- `PALETTES`: List of available color palettes \n- `CONTEXTS`: List of available contexts\n\n## Development\n\n### Requirements\n\n- Python >=3.11\n- matplotlib >=3.5\n- seaborn >=0.11 (for development/generation only)\n\n### Setup\n\n```bash\ngit clone https://github.com/monodera/mplstyles-seaborn.git\ncd mplstyles-seaborn\nuv sync\n```\n\n### Testing\n\nThis project includes comprehensive tests covering:\n- Unit tests for all API functions\n- Integration tests with matplotlib\n- Validation tests for all 120 style files\n- Error handling and edge cases\n- Performance benchmarks\n\n#### Running Tests\n\n```bash\n# Install test dependencies\nuv sync --extra test\n\n# Run all tests\nuv run pytest\n\n# Run tests with coverage\nuv run pytest --cov=src/mplstyles_seaborn --cov-report=term-missing\n\n# Run specific test categories\nuv run pytest tests/test_api.py # API function tests\nuv run pytest tests/test_integration.py # Matplotlib integration tests\nuv run pytest tests/test_styles.py # Style file validation tests\nuv run pytest tests/test_errors.py # Error handling tests\n\n# Run performance tests (marked as slow)\nuv run pytest tests/test_performance.py -m \"not slow\" # Fast performance tests\nuv run pytest tests/test_performance.py # All performance tests\n\n# Run with verbose output\nuv run pytest -v\n```\n\n#### Manual Testing\n\n```bash\n# Test package import and basic functionality\nuv run python -c \"import mplstyles_seaborn; print(len(mplstyles_seaborn.list_available_styles()))\"\n\n# Test specific style application\nuv run python -c \"import matplotlib.pyplot as plt; plt.style.use('seaborn-v0_8-whitegrid-colorblind-talk')\"\n\n# Run example scripts\nuv run python examples/basic_usage.py\nuv run python examples/style_comparison.py\nuv run python examples/comprehensive_demo.py\n```\n\n### Regenerating Styles\n\n```bash\n# Generate and fix all 120 style files in one command (recommended)\nuv run python scripts/build_styles.py\n\n# Alternative: Generate only (for development/testing)\nuv run python scripts/build_styles.py --generate-only\n\n# Alternative: Fix existing files only\nuv run python scripts/build_styles.py --fix-only\n```\n\n## License\n\nThis project is licensed under the MIT License.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Development Support\n\nThis project was primarily developed using [Claude Code](https://claude.ai/code), Anthropic's AI-powered coding assistant.\n\n## Related Projects\n\n- [seaborn](https://seaborn.pydata.org/) - Statistical data visualization library\n- [matplotlib](https://matplotlib.org/) - Python plotting library\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Matplotlib style sheets based on seaborn-v0_8-dark theme with combinable palettes and contexts",
"version": "0.2.5",
"project_urls": {
"Homepage": "https://github.com/monodera/mplstyles-seaborn",
"Issues": "https://github.com/monodera/mplstyles-seaborn/issues",
"Repository": "https://github.com/monodera/mplstyles-seaborn"
},
"split_keywords": [
"matplotlib",
" seaborn",
" plotting",
" visualization",
" styles"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "cfa002e35b29c5ded94644f57393f7f87ecf9c8a9f29b6362ec37a79550247d2",
"md5": "3b51ea627b44d93a6b7fca6228fc70fb",
"sha256": "aabe7b99d5272c3be78de92f62fbf8a839844e37ecfe25ac895e23de1f1eb715"
},
"downloads": -1,
"filename": "mplstyles_seaborn-0.2.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3b51ea627b44d93a6b7fca6228fc70fb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 104022,
"upload_time": "2025-07-31T07:18:09",
"upload_time_iso_8601": "2025-07-31T07:18:09.197069Z",
"url": "https://files.pythonhosted.org/packages/cf/a0/02e35b29c5ded94644f57393f7f87ecf9c8a9f29b6362ec37a79550247d2/mplstyles_seaborn-0.2.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ed6b278de3eff092eb7c2575f8aea5c3c3a8c5ec8c0a19ca0be45954e2cc65e9",
"md5": "4f2361d383c4772ba004339b7ca91021",
"sha256": "448b2df0986970763d44cb8900f50431dc4b5686edfd7dabadd59eb4b2b908e5"
},
"downloads": -1,
"filename": "mplstyles_seaborn-0.2.5.tar.gz",
"has_sig": false,
"md5_digest": "4f2361d383c4772ba004339b7ca91021",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 17516154,
"upload_time": "2025-07-31T07:18:10",
"upload_time_iso_8601": "2025-07-31T07:18:10.981734Z",
"url": "https://files.pythonhosted.org/packages/ed/6b/278de3eff092eb7c2575f8aea5c3c3a8c5ec8c0a19ca0be45954e2cc65e9/mplstyles_seaborn-0.2.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-31 07:18:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "monodera",
"github_project": "mplstyles-seaborn",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "mplstyles-seaborn"
}