Name | fast_fig JSON |
Version |
0.8.0
JSON |
| download |
home_page | None |
Summary | FaSt_Fig is a wrapper for matplotlib with templates. |
upload_time | 2025-08-28 19:36:57 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
matplotlib
figure
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# FaSt_Fig
FaSt_Fig is a wrapper for matplotlib that provides a simple interface for fast and easy plotting.
Key features:
- Predefined templates for consistent styling
- Figure instantiation in a class object
- Simplified plotting methods with smart defaults
- Automatic handling of DataFrames
- Context manager support for clean resource management
- Type hints and logging for better development experience
## Installation
```bash
pip install fast_fig
```
## Basic Usage
```python
from fast_fig import FFig
x = [1,2,3,4,5]
y1 = [2,4,5,6,10]
y2 = [1,3,2,6,9]
# Simple plot example
fig = FFig()
fig.plot(x,y1)
fig.show()
# Use large template and save figure to multiple formats
fig = FFig('l')
fig.plot(x,y)
fig.save('plot.png', 'pdf')
```
## Context Manager
FaSt_Fig can be used as a context manager for automatic resource cleanup:
```python
with FFig('l', nrows=2, sharex=True) as fig: # Large template, 2 rows sharing x-axis
fig.plot([1, 2, 2.5], label="First") # Plot in first axis/subplot
fig.set_title("First plot")
fig.next_axis() # Switch to second axis/subplot
fig.plot([0, 1, 2], [0, 1, 4], label="Second") # Plot with x,y data
fig.legend() # Add legend
fig.grid() # Add grid
fig.set_xlabel("X values") # Label x-axis
fig.save("plot.png", "pdf") # Save as PNG and PDF
# Figure automatically closed when exiting the with block
```
## Plot Types
FaSt_Fig supports all plots of matplotlib.
The following plots have adjusted settings to improve their use.
```python
# Bar plots
fig.bar_plot(x, height)
# Logarithmic scales
fig.semilogx(x, y) # logarithmic x-axis
fig.semilogy(x, y) # logarithmic y-axis
# 2D plots
x, y = np.meshgrid(np.linspace(-2, 2, 100), np.linspace(-2, 2, 100))
z = np.exp(-(x**2 + y**2))
fig.pcolor(z) # pseudocolor plot
fig.colorbar(label='Values') # add colorbar
fig.pcolor_log(z) # pseudocolor with logarithmic color scale
fig.contour(z, levels=[0.2, 0.5, 0.8]) # contour plot
# Scatter plots
fig.scatter(x, y, c=colors, s=sizes) # scatter plot with colors and sizes
```
## DataFrame Support
FaSt_Fig has built-in support for pandas DataFrames:
```python
import pandas as pd
# Create a DataFrame with datetime index
df = pd.DataFrame({
'A': [1, 2, 3, 4],
'B': [2, 4, 6, 8]
}, index=pd.date_range('2024-01-01', periods=4))
fig = FFig()
fig.plot(df) # Automatic handling:
# - Each column becomes a line
# - Column names become labels
# - Index used as x-axis
# - Date index sets x-label to "Date"
```
## Matplotlib interaction
FaSt_Fig provides direct access to matplotlib objects through these handlers:
- `fig.current_axis`: Current axes instance for active subplot
- `fig.handle_fig`: Figure instance for figure-level operations
- `fig.handle_plot`: Current plot instance(s)
- `fig.handle_axis`: All axes instances for subplot access
```python
fig.current_axis.set_yscale('log') # Direct matplotlib axis methods
fig.handle_fig.tight_layout() # Adjust layout
fig.handle_plot[0].set_linewidth(2) # Modify line properties
fig.handle_axis[0].set_title('First subplot') # Access any subplot
```
These handles provide full access to matplotlib's functionality when needed.
## Presets
FaSt_Fig comes with built-in presets that control figure appearance. Available preset templates:
- `m` (medium): 15x10 cm, sans-serif font, good for general use
- `s` (small): 10x8 cm, sans-serif font, suitable for small plots
- `l` (large): 20x15 cm, sans-serif font, ideal for presentations
- `ol` (Optics Letters): 8x6 cm, serif font, optimized for single line plots
- `oe` (Optics Express): 12x8 cm, serif font, designed for equation plots
- `square`: 10x10 cm, serif font, perfect for square plots
Each preset defines:
- `width`: Figure width in cm
- `height`: Figure height in cm
- `fontfamily`: Font family (serif or sans-serif)
- `fontsize`: Font size in points
- `linewidth`: Line width in points
You can use presets in three ways:
1. Use a built-in preset:
```python
fig = FFig('l') # Use large preset
```
2. Load custom presets from a file:
```python
fig = FFig('m', presets='my_presets.yaml') # YAML format
fig = FFig('m', presets='my_presets.json') # or JSON format
```
3. Override specific preset values:
```python
fig = FFig('m', width=12, fontsize=14) # Override width and fontsize
```
The preset system also includes color sequences and line styles that cycle automatically when plotting multiple lines:
- Default colors: blue, red, green, orange
- Default line styles: solid (-), dashed (--), dotted (:), dash-dot (-.)
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
Licensed under MIT License. See [LICENSE](LICENSE) for details.
## Author
Written by Fabian Stutzki (fast@fast-apps.de)
For more information, visit [www.fast-apps.de](https://www.fast-apps.de)
Raw data
{
"_id": null,
"home_page": null,
"name": "fast_fig",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "matplotlib, figure",
"author": null,
"author_email": "Fabian Stutzki <fast@fast-apps.de>",
"download_url": "https://files.pythonhosted.org/packages/f6/70/c0cc7bafdfdf835a3af4a857fb453fd57662de09277b16366dd7ff25234a/fast_fig-0.8.0.tar.gz",
"platform": null,
"description": "# FaSt_Fig\nFaSt_Fig is a wrapper for matplotlib that provides a simple interface for fast and easy plotting.\n\nKey features:\n- Predefined templates for consistent styling\n- Figure instantiation in a class object\n- Simplified plotting methods with smart defaults\n- Automatic handling of DataFrames\n- Context manager support for clean resource management\n- Type hints and logging for better development experience\n\n## Installation\n\n```bash\npip install fast_fig\n```\n\n## Basic Usage\n\n```python\nfrom fast_fig import FFig\nx = [1,2,3,4,5]\ny1 = [2,4,5,6,10]\ny2 = [1,3,2,6,9]\n\n# Simple plot example\nfig = FFig()\nfig.plot(x,y1)\nfig.show()\n\n# Use large template and save figure to multiple formats\nfig = FFig('l')\nfig.plot(x,y)\nfig.save('plot.png', 'pdf')\n```\n\n## Context Manager\n\nFaSt_Fig can be used as a context manager for automatic resource cleanup:\n\n```python\nwith FFig('l', nrows=2, sharex=True) as fig: # Large template, 2 rows sharing x-axis\n fig.plot([1, 2, 2.5], label=\"First\") # Plot in first axis/subplot\n fig.set_title(\"First plot\")\n fig.next_axis() # Switch to second axis/subplot\n fig.plot([0, 1, 2], [0, 1, 4], label=\"Second\") # Plot with x,y data\n fig.legend() # Add legend\n fig.grid() # Add grid\n fig.set_xlabel(\"X values\") # Label x-axis\n fig.save(\"plot.png\", \"pdf\") # Save as PNG and PDF\n # Figure automatically closed when exiting the with block\n```\n\n## Plot Types\n\nFaSt_Fig supports all plots of matplotlib.\nThe following plots have adjusted settings to improve their use.\n\n```python\n# Bar plots\nfig.bar_plot(x, height)\n\n# Logarithmic scales\nfig.semilogx(x, y) # logarithmic x-axis\nfig.semilogy(x, y) # logarithmic y-axis\n\n# 2D plots\nx, y = np.meshgrid(np.linspace(-2, 2, 100), np.linspace(-2, 2, 100))\nz = np.exp(-(x**2 + y**2))\n\nfig.pcolor(z) # pseudocolor plot\nfig.colorbar(label='Values') # add colorbar\n\n\nfig.pcolor_log(z) # pseudocolor with logarithmic color scale\n\nfig.contour(z, levels=[0.2, 0.5, 0.8]) # contour plot\n\n# Scatter plots\nfig.scatter(x, y, c=colors, s=sizes) # scatter plot with colors and sizes\n```\n\n## DataFrame Support\n\nFaSt_Fig has built-in support for pandas DataFrames:\n\n```python\nimport pandas as pd\n\n# Create a DataFrame with datetime index\ndf = pd.DataFrame({\n 'A': [1, 2, 3, 4],\n 'B': [2, 4, 6, 8]\n}, index=pd.date_range('2024-01-01', periods=4))\n\nfig = FFig()\nfig.plot(df) # Automatic handling:\n # - Each column becomes a line\n # - Column names become labels\n # - Index used as x-axis\n # - Date index sets x-label to \"Date\"\n```\n\n## Matplotlib interaction\n\nFaSt_Fig provides direct access to matplotlib objects through these handlers:\n\n- `fig.current_axis`: Current axes instance for active subplot\n- `fig.handle_fig`: Figure instance for figure-level operations\n- `fig.handle_plot`: Current plot instance(s)\n- `fig.handle_axis`: All axes instances for subplot access\n```python\nfig.current_axis.set_yscale('log') # Direct matplotlib axis methods\nfig.handle_fig.tight_layout() # Adjust layout\nfig.handle_plot[0].set_linewidth(2) # Modify line properties\nfig.handle_axis[0].set_title('First subplot') # Access any subplot\n```\n\nThese handles provide full access to matplotlib's functionality when needed.\n\n## Presets\n\nFaSt_Fig comes with built-in presets that control figure appearance. Available preset templates:\n\n- `m` (medium): 15x10 cm, sans-serif font, good for general use\n- `s` (small): 10x8 cm, sans-serif font, suitable for small plots\n- `l` (large): 20x15 cm, sans-serif font, ideal for presentations\n- `ol` (Optics Letters): 8x6 cm, serif font, optimized for single line plots\n- `oe` (Optics Express): 12x8 cm, serif font, designed for equation plots\n- `square`: 10x10 cm, serif font, perfect for square plots\n\nEach preset defines:\n- `width`: Figure width in cm\n- `height`: Figure height in cm\n- `fontfamily`: Font family (serif or sans-serif)\n- `fontsize`: Font size in points\n- `linewidth`: Line width in points\n\nYou can use presets in three ways:\n\n1. Use a built-in preset:\n```python\nfig = FFig('l') # Use large preset\n```\n\n2. Load custom presets from a file:\n```python\nfig = FFig('m', presets='my_presets.yaml') # YAML format\nfig = FFig('m', presets='my_presets.json') # or JSON format\n```\n\n3. Override specific preset values:\n```python\nfig = FFig('m', width=12, fontsize=14) # Override width and fontsize\n```\n\nThe preset system also includes color sequences and line styles that cycle automatically when plotting multiple lines:\n- Default colors: blue, red, green, orange\n- Default line styles: solid (-), dashed (--), dotted (:), dash-dot (-.)\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nLicensed under MIT License. See [LICENSE](LICENSE) for details.\n\n## Author\n\nWritten by Fabian Stutzki (fast@fast-apps.de)\n\nFor more information, visit [www.fast-apps.de](https://www.fast-apps.de)\n",
"bugtrack_url": null,
"license": null,
"summary": "FaSt_Fig is a wrapper for matplotlib with templates.",
"version": "0.8.0",
"project_urls": null,
"split_keywords": [
"matplotlib",
" figure"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "68a76144e18e2f2ae6ff2911a50183c2a782b80261729d724adc1d6b666028ea",
"md5": "2ada4c7793620d43737268765e9e3c90",
"sha256": "21c1da83b54423391e8c3a9c66afe34c82410c4bd63fc6895a8c46dc568bc3bc"
},
"downloads": -1,
"filename": "fast_fig-0.8.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2ada4c7793620d43737268765e9e3c90",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 16673,
"upload_time": "2025-08-28T19:36:56",
"upload_time_iso_8601": "2025-08-28T19:36:56.451927Z",
"url": "https://files.pythonhosted.org/packages/68/a7/6144e18e2f2ae6ff2911a50183c2a782b80261729d724adc1d6b666028ea/fast_fig-0.8.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f670c0cc7bafdfdf835a3af4a857fb453fd57662de09277b16366dd7ff25234a",
"md5": "6ccba52d8a611e50f7e5a28e29c85cf7",
"sha256": "58a5f90b940e3eaba27a0aed24a3381f0414ddf9d34743f36c00756dd5fab5c4"
},
"downloads": -1,
"filename": "fast_fig-0.8.0.tar.gz",
"has_sig": false,
"md5_digest": "6ccba52d8a611e50f7e5a28e29c85cf7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 22236,
"upload_time": "2025-08-28T19:36:57",
"upload_time_iso_8601": "2025-08-28T19:36:57.345570Z",
"url": "https://files.pythonhosted.org/packages/f6/70/c0cc7bafdfdf835a3af4a857fb453fd57662de09277b16366dd7ff25234a/fast_fig-0.8.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-28 19:36:57",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "fast_fig"
}