fast-fig 0.8.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fast_fig-0.8.4/LICENSE +21 -0
- fast_fig-0.8.4/PKG-INFO +201 -0
- fast_fig-0.8.4/README.md +173 -0
- fast_fig-0.8.4/fast_fig/__init__.py +6 -0
- fast_fig-0.8.4/fast_fig/class_ffig.py +1420 -0
- fast_fig-0.8.4/fast_fig/presets.py +243 -0
- fast_fig-0.8.4/fast_fig.egg-info/PKG-INFO +201 -0
- fast_fig-0.8.4/fast_fig.egg-info/SOURCES.txt +24 -0
- fast_fig-0.8.4/fast_fig.egg-info/dependency_links.txt +1 -0
- fast_fig-0.8.4/fast_fig.egg-info/requires.txt +4 -0
- fast_fig-0.8.4/fast_fig.egg-info/top_level.txt +1 -0
- fast_fig-0.8.4/pyproject.toml +80 -0
- fast_fig-0.8.4/setup.cfg +4 -0
- fast_fig-0.8.4/tests/test_axes_config.py +69 -0
- fast_fig-0.8.4/tests/test_colors.py +55 -0
- fast_fig-0.8.4/tests/test_compat.py +45 -0
- fast_fig-0.8.4/tests/test_get_all_labels.py +70 -0
- fast_fig-0.8.4/tests/test_lifecycle.py +163 -0
- fast_fig-0.8.4/tests/test_plotting.py +241 -0
- fast_fig-0.8.4/tests/test_presets.py +246 -0
- fast_fig-0.8.4/tests/test_references.py +213 -0
- fast_fig-0.8.4/tests/test_save.py +85 -0
- fast_fig-0.8.4/tests/test_set_limits_same_minmax.py +95 -0
- fast_fig-0.8.4/tests/test_subplots.py +117 -0
- fast_fig-0.8.4/tests/test_title.py +73 -0
- fast_fig-0.8.4/tests/test_typing.py +248 -0
fast_fig-0.8.4/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Fabian Stutzki
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
fast_fig-0.8.4/PKG-INFO
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fast_fig
|
|
3
|
+
Version: 0.8.4
|
|
4
|
+
Summary: FaSt_Fig is a wrapper for matplotlib with templates.
|
|
5
|
+
Author-email: Fabian Stutzki <fast@fast-apps.de>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://www.fast-apps.de
|
|
8
|
+
Project-URL: Repository, https://codeberg.org/FaSt-Apps/FaSt_Fig
|
|
9
|
+
Project-URL: Issues, https://codeberg.org/FaSt-Apps/FaSt_Fig/issues
|
|
10
|
+
Project-URL: Changelog, https://codeberg.org/FaSt-Apps/FaSt_Fig/src/branch/main/CHANGELOG.md
|
|
11
|
+
Keywords: matplotlib,figure
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Requires-Python: >=3.12
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: numpy>=1.26.0
|
|
24
|
+
Requires-Dist: matplotlib>=3.6.0
|
|
25
|
+
Requires-Dist: pandas>=2.1.0
|
|
26
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# FaSt_Fig
|
|
30
|
+
FaSt_Fig is a wrapper for matplotlib that provides a simple interface for fast and easy plotting.
|
|
31
|
+
|
|
32
|
+
Key features:
|
|
33
|
+
- Predefined templates for consistent styling
|
|
34
|
+
- Figure instantiation in a class object
|
|
35
|
+
- Simplified plotting methods with smart defaults
|
|
36
|
+
- Automatic handling of DataFrames
|
|
37
|
+
- Context manager support for clean resource management
|
|
38
|
+
- Type hints and logging for better development experience
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install fast_fig
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Basic Usage
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from fast_fig import FFig
|
|
50
|
+
|
|
51
|
+
x = [1, 2, 3, 4, 5]
|
|
52
|
+
y1 = [2, 4, 5, 6, 10]
|
|
53
|
+
y2 = [1, 3, 2, 6, 9]
|
|
54
|
+
|
|
55
|
+
# Simple plot example
|
|
56
|
+
fig = FFig()
|
|
57
|
+
fig.plot(x, y1)
|
|
58
|
+
fig.show()
|
|
59
|
+
|
|
60
|
+
# Use large template and save figure to multiple formats
|
|
61
|
+
fig = FFig("l")
|
|
62
|
+
fig.plot(x, y)
|
|
63
|
+
fig.save("plot.png", "pdf")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Context Manager
|
|
67
|
+
|
|
68
|
+
FaSt_Fig can be used as a context manager for automatic resource cleanup:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
with FFig("l", nrows=2, sharex=True) as fig: # Large template, 2 rows sharing x-axis
|
|
72
|
+
fig.plot([1, 2, 2.5], label="First") # Plot in first axis/subplot
|
|
73
|
+
fig.set_title("First plot")
|
|
74
|
+
fig.next_axis() # Switch to second axis/subplot
|
|
75
|
+
fig.plot([0, 1, 2], [0, 1, 4], label="Second") # Plot with x,y data
|
|
76
|
+
fig.legend() # Add legend
|
|
77
|
+
fig.grid() # Add grid
|
|
78
|
+
fig.set_xlabel("X values") # Label x-axis
|
|
79
|
+
fig.save("plot.png", "pdf") # Save as PNG and PDF
|
|
80
|
+
# Figure automatically closed when exiting the with block
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Plot Types
|
|
84
|
+
|
|
85
|
+
FaSt_Fig supports all plots of matplotlib.
|
|
86
|
+
The following plots have adjusted settings to improve their use.
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
# Bar plots
|
|
90
|
+
fig.bar_plot(x, height)
|
|
91
|
+
|
|
92
|
+
# Logarithmic scales
|
|
93
|
+
fig.semilogx(x, y) # logarithmic x-axis
|
|
94
|
+
fig.semilogy(x, y) # logarithmic y-axis
|
|
95
|
+
|
|
96
|
+
# 2D plots
|
|
97
|
+
x, y = np.meshgrid(np.linspace(-2, 2, 100), np.linspace(-2, 2, 100))
|
|
98
|
+
z = np.exp(-(x**2 + y**2))
|
|
99
|
+
|
|
100
|
+
fig.pcolor(z) # pseudocolor plot
|
|
101
|
+
fig.colorbar(label="Values") # add colorbar
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
fig.pcolor_log(z) # pseudocolor with logarithmic color scale
|
|
105
|
+
|
|
106
|
+
fig.contour(z, levels=[0.2, 0.5, 0.8]) # contour plot
|
|
107
|
+
|
|
108
|
+
# Scatter plots
|
|
109
|
+
fig.scatter(x, y, c=colors, s=sizes) # scatter plot with colors and sizes
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## DataFrame Support
|
|
113
|
+
|
|
114
|
+
FaSt_Fig has built-in support for pandas DataFrames:
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
import pandas as pd
|
|
118
|
+
|
|
119
|
+
# Create a DataFrame with datetime index
|
|
120
|
+
df = pd.DataFrame(
|
|
121
|
+
{"A": [1, 2, 3, 4], "B": [2, 4, 6, 8]}, index=pd.date_range("2024-01-01", periods=4)
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
fig = FFig()
|
|
125
|
+
fig.plot(df) # Automatic handling:
|
|
126
|
+
# - Each column becomes a line
|
|
127
|
+
# - Column names become labels
|
|
128
|
+
# - Index used as x-axis
|
|
129
|
+
# - Date index sets x-label to "Date"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Matplotlib interaction
|
|
133
|
+
|
|
134
|
+
FaSt_Fig provides direct access to matplotlib objects through these handlers:
|
|
135
|
+
|
|
136
|
+
- `fig.current_axis`: Current axes instance for active subplot
|
|
137
|
+
- `fig.handle_fig`: Figure instance for figure-level operations
|
|
138
|
+
- `fig.handle_plot`: Current plot instance(s)
|
|
139
|
+
- `fig.handle_axis`: All axes instances for subplot access
|
|
140
|
+
```python
|
|
141
|
+
fig.current_axis.set_yscale("log") # Direct matplotlib axis methods
|
|
142
|
+
fig.handle_fig.tight_layout() # Adjust layout
|
|
143
|
+
fig.handle_plot[0].set_linewidth(2) # Modify line properties
|
|
144
|
+
fig.handle_axis[0].set_title("First subplot") # Access any subplot
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
These handles provide full access to matplotlib's functionality when needed.
|
|
148
|
+
|
|
149
|
+
## Presets
|
|
150
|
+
|
|
151
|
+
FaSt_Fig comes with built-in presets that control figure appearance. Available preset templates:
|
|
152
|
+
|
|
153
|
+
- `m` (medium): 15x10 cm, sans-serif font, good for general use
|
|
154
|
+
- `s` (small): 10x8 cm, sans-serif font, suitable for small plots
|
|
155
|
+
- `l` (large): 20x15 cm, sans-serif font, ideal for presentations
|
|
156
|
+
- `ol` (Optics Letters): 8x6 cm, serif font, optimized for single line plots
|
|
157
|
+
- `oe` (Optics Express): 12x8 cm, serif font, designed for equation plots
|
|
158
|
+
- `square`: 10x10 cm, serif font, perfect for square plots
|
|
159
|
+
|
|
160
|
+
Each preset defines:
|
|
161
|
+
- `width`: Figure width in cm
|
|
162
|
+
- `height`: Figure height in cm
|
|
163
|
+
- `fontfamily`: Font family (serif or sans-serif)
|
|
164
|
+
- `fontsize`: Font size in points
|
|
165
|
+
- `linewidth`: Line width in points
|
|
166
|
+
|
|
167
|
+
You can use presets in three ways:
|
|
168
|
+
|
|
169
|
+
1. Use a built-in preset:
|
|
170
|
+
```python
|
|
171
|
+
fig = FFig("l") # Use large preset
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
2. Load custom presets from a file:
|
|
175
|
+
```python
|
|
176
|
+
fig = FFig("m", presets="my_presets.yaml") # YAML format
|
|
177
|
+
fig = FFig("m", presets="my_presets.json") # or JSON format
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
3. Override specific preset values:
|
|
181
|
+
```python
|
|
182
|
+
fig = FFig("m", width=12, fontsize=14) # Override width and fontsize
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The preset system also includes color sequences and line styles that cycle automatically when plotting multiple lines:
|
|
186
|
+
- Default colors: blue, red, green, orange
|
|
187
|
+
- Default line styles: solid (-), dashed (--), dotted (:), dash-dot (-.)
|
|
188
|
+
|
|
189
|
+
## Contributing
|
|
190
|
+
|
|
191
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
Licensed under MIT License. See [LICENSE](LICENSE) for details.
|
|
196
|
+
|
|
197
|
+
## Author
|
|
198
|
+
|
|
199
|
+
Written by Fabian Stutzki (fast@fast-apps.de)
|
|
200
|
+
|
|
201
|
+
For more information, visit [www.fast-apps.de](https://www.fast-apps.de)
|
fast_fig-0.8.4/README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# FaSt_Fig
|
|
2
|
+
FaSt_Fig is a wrapper for matplotlib that provides a simple interface for fast and easy plotting.
|
|
3
|
+
|
|
4
|
+
Key features:
|
|
5
|
+
- Predefined templates for consistent styling
|
|
6
|
+
- Figure instantiation in a class object
|
|
7
|
+
- Simplified plotting methods with smart defaults
|
|
8
|
+
- Automatic handling of DataFrames
|
|
9
|
+
- Context manager support for clean resource management
|
|
10
|
+
- Type hints and logging for better development experience
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install fast_fig
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Basic Usage
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from fast_fig import FFig
|
|
22
|
+
|
|
23
|
+
x = [1, 2, 3, 4, 5]
|
|
24
|
+
y1 = [2, 4, 5, 6, 10]
|
|
25
|
+
y2 = [1, 3, 2, 6, 9]
|
|
26
|
+
|
|
27
|
+
# Simple plot example
|
|
28
|
+
fig = FFig()
|
|
29
|
+
fig.plot(x, y1)
|
|
30
|
+
fig.show()
|
|
31
|
+
|
|
32
|
+
# Use large template and save figure to multiple formats
|
|
33
|
+
fig = FFig("l")
|
|
34
|
+
fig.plot(x, y)
|
|
35
|
+
fig.save("plot.png", "pdf")
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Context Manager
|
|
39
|
+
|
|
40
|
+
FaSt_Fig can be used as a context manager for automatic resource cleanup:
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
with FFig("l", nrows=2, sharex=True) as fig: # Large template, 2 rows sharing x-axis
|
|
44
|
+
fig.plot([1, 2, 2.5], label="First") # Plot in first axis/subplot
|
|
45
|
+
fig.set_title("First plot")
|
|
46
|
+
fig.next_axis() # Switch to second axis/subplot
|
|
47
|
+
fig.plot([0, 1, 2], [0, 1, 4], label="Second") # Plot with x,y data
|
|
48
|
+
fig.legend() # Add legend
|
|
49
|
+
fig.grid() # Add grid
|
|
50
|
+
fig.set_xlabel("X values") # Label x-axis
|
|
51
|
+
fig.save("plot.png", "pdf") # Save as PNG and PDF
|
|
52
|
+
# Figure automatically closed when exiting the with block
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Plot Types
|
|
56
|
+
|
|
57
|
+
FaSt_Fig supports all plots of matplotlib.
|
|
58
|
+
The following plots have adjusted settings to improve their use.
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
# Bar plots
|
|
62
|
+
fig.bar_plot(x, height)
|
|
63
|
+
|
|
64
|
+
# Logarithmic scales
|
|
65
|
+
fig.semilogx(x, y) # logarithmic x-axis
|
|
66
|
+
fig.semilogy(x, y) # logarithmic y-axis
|
|
67
|
+
|
|
68
|
+
# 2D plots
|
|
69
|
+
x, y = np.meshgrid(np.linspace(-2, 2, 100), np.linspace(-2, 2, 100))
|
|
70
|
+
z = np.exp(-(x**2 + y**2))
|
|
71
|
+
|
|
72
|
+
fig.pcolor(z) # pseudocolor plot
|
|
73
|
+
fig.colorbar(label="Values") # add colorbar
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
fig.pcolor_log(z) # pseudocolor with logarithmic color scale
|
|
77
|
+
|
|
78
|
+
fig.contour(z, levels=[0.2, 0.5, 0.8]) # contour plot
|
|
79
|
+
|
|
80
|
+
# Scatter plots
|
|
81
|
+
fig.scatter(x, y, c=colors, s=sizes) # scatter plot with colors and sizes
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## DataFrame Support
|
|
85
|
+
|
|
86
|
+
FaSt_Fig has built-in support for pandas DataFrames:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
import pandas as pd
|
|
90
|
+
|
|
91
|
+
# Create a DataFrame with datetime index
|
|
92
|
+
df = pd.DataFrame(
|
|
93
|
+
{"A": [1, 2, 3, 4], "B": [2, 4, 6, 8]}, index=pd.date_range("2024-01-01", periods=4)
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
fig = FFig()
|
|
97
|
+
fig.plot(df) # Automatic handling:
|
|
98
|
+
# - Each column becomes a line
|
|
99
|
+
# - Column names become labels
|
|
100
|
+
# - Index used as x-axis
|
|
101
|
+
# - Date index sets x-label to "Date"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Matplotlib interaction
|
|
105
|
+
|
|
106
|
+
FaSt_Fig provides direct access to matplotlib objects through these handlers:
|
|
107
|
+
|
|
108
|
+
- `fig.current_axis`: Current axes instance for active subplot
|
|
109
|
+
- `fig.handle_fig`: Figure instance for figure-level operations
|
|
110
|
+
- `fig.handle_plot`: Current plot instance(s)
|
|
111
|
+
- `fig.handle_axis`: All axes instances for subplot access
|
|
112
|
+
```python
|
|
113
|
+
fig.current_axis.set_yscale("log") # Direct matplotlib axis methods
|
|
114
|
+
fig.handle_fig.tight_layout() # Adjust layout
|
|
115
|
+
fig.handle_plot[0].set_linewidth(2) # Modify line properties
|
|
116
|
+
fig.handle_axis[0].set_title("First subplot") # Access any subplot
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
These handles provide full access to matplotlib's functionality when needed.
|
|
120
|
+
|
|
121
|
+
## Presets
|
|
122
|
+
|
|
123
|
+
FaSt_Fig comes with built-in presets that control figure appearance. Available preset templates:
|
|
124
|
+
|
|
125
|
+
- `m` (medium): 15x10 cm, sans-serif font, good for general use
|
|
126
|
+
- `s` (small): 10x8 cm, sans-serif font, suitable for small plots
|
|
127
|
+
- `l` (large): 20x15 cm, sans-serif font, ideal for presentations
|
|
128
|
+
- `ol` (Optics Letters): 8x6 cm, serif font, optimized for single line plots
|
|
129
|
+
- `oe` (Optics Express): 12x8 cm, serif font, designed for equation plots
|
|
130
|
+
- `square`: 10x10 cm, serif font, perfect for square plots
|
|
131
|
+
|
|
132
|
+
Each preset defines:
|
|
133
|
+
- `width`: Figure width in cm
|
|
134
|
+
- `height`: Figure height in cm
|
|
135
|
+
- `fontfamily`: Font family (serif or sans-serif)
|
|
136
|
+
- `fontsize`: Font size in points
|
|
137
|
+
- `linewidth`: Line width in points
|
|
138
|
+
|
|
139
|
+
You can use presets in three ways:
|
|
140
|
+
|
|
141
|
+
1. Use a built-in preset:
|
|
142
|
+
```python
|
|
143
|
+
fig = FFig("l") # Use large preset
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
2. Load custom presets from a file:
|
|
147
|
+
```python
|
|
148
|
+
fig = FFig("m", presets="my_presets.yaml") # YAML format
|
|
149
|
+
fig = FFig("m", presets="my_presets.json") # or JSON format
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
3. Override specific preset values:
|
|
153
|
+
```python
|
|
154
|
+
fig = FFig("m", width=12, fontsize=14) # Override width and fontsize
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The preset system also includes color sequences and line styles that cycle automatically when plotting multiple lines:
|
|
158
|
+
- Default colors: blue, red, green, orange
|
|
159
|
+
- Default line styles: solid (-), dashed (--), dotted (:), dash-dot (-.)
|
|
160
|
+
|
|
161
|
+
## Contributing
|
|
162
|
+
|
|
163
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
Licensed under MIT License. See [LICENSE](LICENSE) for details.
|
|
168
|
+
|
|
169
|
+
## Author
|
|
170
|
+
|
|
171
|
+
Written by Fabian Stutzki (fast@fast-apps.de)
|
|
172
|
+
|
|
173
|
+
For more information, visit [www.fast-apps.de](https://www.fast-apps.de)
|