bottleviz 0.1.0__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.
- bottleviz-0.1.0/LICENSE +21 -0
- bottleviz-0.1.0/MANIFEST.in +12 -0
- bottleviz-0.1.0/PKG-INFO +536 -0
- bottleviz-0.1.0/README.md +483 -0
- bottleviz-0.1.0/examples/all_3d_plots.py +121 -0
- bottleviz-0.1.0/examples/array_slices_3d.py +86 -0
- bottleviz-0.1.0/examples/auto_detect.py +10 -0
- bottleviz-0.1.0/examples/dashboard_showcase.py +199 -0
- bottleviz-0.1.0/examples/demo.py +151 -0
- bottleviz-0.1.0/examples/demo_show_close.py +48 -0
- bottleviz-0.1.0/examples/example.py +363 -0
- bottleviz-0.1.0/examples/test_large_data.py +43 -0
- bottleviz-0.1.0/pyproject.toml +89 -0
- bottleviz-0.1.0/setup.cfg +4 -0
- bottleviz-0.1.0/src/bottleviz/__init__.py +65 -0
- bottleviz-0.1.0/src/bottleviz/core/core.py +573 -0
- bottleviz-0.1.0/src/bottleviz/core/exceptions.py +179 -0
- bottleviz-0.1.0/src/bottleviz/core/styles.py +254 -0
- bottleviz-0.1.0/src/bottleviz/core/types.py +333 -0
- bottleviz-0.1.0/src/bottleviz/processors/auto.py +256 -0
- bottleviz-0.1.0/src/bottleviz/publishers/backends.py +1229 -0
- bottleviz-0.1.0/src/bottleviz/utils/utils.py +332 -0
- bottleviz-0.1.0/src/bottleviz.egg-info/PKG-INFO +536 -0
- bottleviz-0.1.0/src/bottleviz.egg-info/SOURCES.txt +29 -0
- bottleviz-0.1.0/src/bottleviz.egg-info/dependency_links.txt +1 -0
- bottleviz-0.1.0/src/bottleviz.egg-info/requires.txt +32 -0
- bottleviz-0.1.0/src/bottleviz.egg-info/top_level.txt +1 -0
- bottleviz-0.1.0/tests/__init__.py +3 -0
- bottleviz-0.1.0/tests/test_advanced_plots.py +218 -0
- bottleviz-0.1.0/tests/test_core.py +282 -0
- bottleviz-0.1.0/tests/validate.py +189 -0
bottleviz-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DHS
|
|
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.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
include pyproject.toml
|
|
4
|
+
recursive-include tests *
|
|
5
|
+
recursive-include examples *
|
|
6
|
+
recursive-include docs *
|
|
7
|
+
global-exclude *.pyc
|
|
8
|
+
global-exclude __pycache__
|
|
9
|
+
global-exclude .DS_Store
|
|
10
|
+
prune .git
|
|
11
|
+
prune .venv
|
|
12
|
+
prune venv
|
bottleviz-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bottleviz
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A modern Python data visualization library with smart defaults
|
|
5
|
+
Author-email: BottleViz Team <bottleviz@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/bottleviz/bottleviz
|
|
8
|
+
Project-URL: Documentation, https://bottleviz.readthedocs.io
|
|
9
|
+
Project-URL: Repository, https://github.com/bottleviz/bottleviz
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/bottleviz/bottleviz/issues
|
|
11
|
+
Keywords: visualization,plotting,matplotlib,seaborn,data-science
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: numpy>=1.18.0
|
|
27
|
+
Requires-Dist: pandas>=1.0.0
|
|
28
|
+
Requires-Dist: matplotlib>=3.0.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
32
|
+
Requires-Dist: black>=21.0; extra == "dev"
|
|
33
|
+
Requires-Dist: flake8; extra == "dev"
|
|
34
|
+
Requires-Dist: mypy; extra == "dev"
|
|
35
|
+
Requires-Dist: jupyter; extra == "dev"
|
|
36
|
+
Requires-Dist: ipython; extra == "dev"
|
|
37
|
+
Provides-Extra: plotly
|
|
38
|
+
Requires-Dist: plotly>=5.0.0; extra == "plotly"
|
|
39
|
+
Provides-Extra: datashader
|
|
40
|
+
Requires-Dist: datashader>=0.13.0; extra == "datashader"
|
|
41
|
+
Provides-Extra: network
|
|
42
|
+
Requires-Dist: networkx>=2.0; extra == "network"
|
|
43
|
+
Provides-Extra: treemap
|
|
44
|
+
Requires-Dist: squarify>=0.4.0; extra == "treemap"
|
|
45
|
+
Provides-Extra: all
|
|
46
|
+
Requires-Dist: plotly>=5.0.0; extra == "all"
|
|
47
|
+
Requires-Dist: datashader>=0.13.0; extra == "all"
|
|
48
|
+
Requires-Dist: networkx>=2.0; extra == "all"
|
|
49
|
+
Requires-Dist: squarify>=0.4.0; extra == "all"
|
|
50
|
+
Requires-Dist: scipy>=1.6.0; extra == "all"
|
|
51
|
+
Requires-Dist: polars>=0.19.0; extra == "all"
|
|
52
|
+
Dynamic: license-file
|
|
53
|
+
|
|
54
|
+
# BottleViz
|
|
55
|
+
|
|
56
|
+
**A modern Python data visualization library with smart defaults.**
|
|
57
|
+
|
|
58
|
+
BottleViz addresses the gaps in Matplotlib, Seaborn, and Plotly by providing a simplified, intuitive API with beautiful defaults out of the box, excellent performance with large datasets, and seamless integration with pandas and polars.
|
|
59
|
+
|
|
60
|
+
## Key Features
|
|
61
|
+
|
|
62
|
+
### 1. **Simplified API**
|
|
63
|
+
One function handles most use cases:
|
|
64
|
+
```python
|
|
65
|
+
import bottleviz as vz
|
|
66
|
+
vz.plot(df, x='column1', y='column2') # All in one line!
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
vs. Matplotlib:
|
|
70
|
+
```python
|
|
71
|
+
fig, ax = plt.subplots()
|
|
72
|
+
ax.scatter(df['column1'], df['column2'])
|
|
73
|
+
ax.set_xlabel('column1')
|
|
74
|
+
ax.set_ylabel('column2')
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 2. **Intelligent Plot Type Detection**
|
|
78
|
+
BottleViz automatically chooses the right plot type based on your data:
|
|
79
|
+
- Scatter for two numeric columns
|
|
80
|
+
- Line for time-series data
|
|
81
|
+
- Histogram for single numeric column
|
|
82
|
+
- Bar for categorical data
|
|
83
|
+
- Box/violin for distributions
|
|
84
|
+
- Heatmap for correlations
|
|
85
|
+
- Sankey for flow diagrams
|
|
86
|
+
- Sunburst/Treemap for hierarchical data
|
|
87
|
+
- Network graphs for relationships
|
|
88
|
+
- Candlestick for financial OHLC data
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
vz.plot(df) # Auto-detects appropriate visualization!
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### 3. **Beautiful Defaults**
|
|
95
|
+
Stunning visualizations with zero configuration:
|
|
96
|
+
- Modern color palettes (colorblind-friendly)
|
|
97
|
+
- Professional typography
|
|
98
|
+
- Optimized layout and sizing
|
|
99
|
+
- Publication-ready styles
|
|
100
|
+
- Dark mode support
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
vz.set_style('dark') # Multiple presets available
|
|
104
|
+
vz.plot(df) # Automatically looks great
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 4. **Excellent Performance**
|
|
108
|
+
Optimized for large datasets:
|
|
109
|
+
- Smart downsampling for >10k points
|
|
110
|
+
- Optional GPU acceleration
|
|
111
|
+
- Datashader backend for millions of points
|
|
112
|
+
- Lazy evaluation where applicable
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
vz.plot(large_df) # Handles 1M+ rows smoothly
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 5. **Seamless Dataframe Integration**
|
|
119
|
+
Works perfectly with pandas, polars, and more:
|
|
120
|
+
```python
|
|
121
|
+
vz.plot(df, x='date', y='sales')
|
|
122
|
+
vz.plot(polars_df, x='col1', y='col2')
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 6. **Unified Interface**
|
|
126
|
+
One consistent API across all plot types:
|
|
127
|
+
```python
|
|
128
|
+
vz.plot(df, x='col1', y='col2', kind='scatter') # Same interface
|
|
129
|
+
vz.plot(df, x='col1', y='col2', kind='line')
|
|
130
|
+
vz.plot(df, x='col1', y='col2', kind='bar')
|
|
131
|
+
vz.plot(df, kind='hist') # Even works without x/y
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 7. **Advanced Visualizations**
|
|
135
|
+
Explore complex data relationships with specialized chart types:
|
|
136
|
+
|
|
137
|
+
**Sankey Diagrams** - Flow between stages/categories
|
|
138
|
+
```python
|
|
139
|
+
vz.plot(flow_data, kind='sankey', source='from', target='to', value='count')
|
|
140
|
+
```
|
|
141
|
+
*Requires: `networkx`*
|
|
142
|
+
|
|
143
|
+
**Sunburst Charts** - Hierarchical radial layouts
|
|
144
|
+
```python
|
|
145
|
+
vz.plot(hierarchy_data, kind='sunburst', path=['region', 'city'], value='sales')
|
|
146
|
+
```
|
|
147
|
+
*Optional: `squarify` for treemap variant*
|
|
148
|
+
|
|
149
|
+
**Treemaps** - Hierarchical rectangular layouts
|
|
150
|
+
```python
|
|
151
|
+
vz.plot(hierarchy_data, kind='treemap', path=['region', 'city'], value='sales')
|
|
152
|
+
```
|
|
153
|
+
*Requires: `squarify`*
|
|
154
|
+
|
|
155
|
+
**Network Graphs** - Visualize relationships and connections
|
|
156
|
+
```python
|
|
157
|
+
vz.plot(edges, kind='network', source='node1', target='node2', layout='spring')
|
|
158
|
+
```
|
|
159
|
+
*Requires: `networkx`*
|
|
160
|
+
|
|
161
|
+
**Candlestick Charts** - Financial OHLC time series
|
|
162
|
+
```python
|
|
163
|
+
vz.plot(stock_data, x='date', kind='candlestick', open='open', high='high', low='low', close='close')
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**3D Visualizations** - Comprehensive 3D plotting suite
|
|
167
|
+
```python
|
|
168
|
+
# Surface plot (points connected by planes)
|
|
169
|
+
fig, ax = vz.plot_3d_surface(X, Y, Z, title='Surface', cmap='viridis')
|
|
170
|
+
|
|
171
|
+
# Wireframe mesh
|
|
172
|
+
fig, ax = vz.plot_3d_wireframe(X, Y, Z, title='Wireframe')
|
|
173
|
+
|
|
174
|
+
# Triangular surface (for scattered data)
|
|
175
|
+
fig, ax = vz.plot_3d_trisurf(x, y, z, title='Triangular Surface')
|
|
176
|
+
|
|
177
|
+
# Contour lines and filled contours
|
|
178
|
+
fig, ax = vz.plot_3d_contour(X, Y, Z, levels=15)
|
|
179
|
+
fig, ax = vz.plot_3d_contourf(X, Y, Z, levels=20)
|
|
180
|
+
|
|
181
|
+
# Vector field (arrows)
|
|
182
|
+
fig, ax = vz.plot_3d_quiver(X, Y, Z, U, V, W, title='Vector Field')
|
|
183
|
+
|
|
184
|
+
# 3D stem plot
|
|
185
|
+
fig, ax = vz.plot_3d_stem(x, y, z, title='3D Stem')
|
|
186
|
+
|
|
187
|
+
# 3D bar chart
|
|
188
|
+
fig, ax = vz.plot_3d_bar(x, y, z, dx, dy, dz, title='3D Bars')
|
|
189
|
+
|
|
190
|
+
# 3D voxel/volume rendering
|
|
191
|
+
fig, ax = vz.plot_3d_voxels(voxel_array, title='3D Voxels')
|
|
192
|
+
|
|
193
|
+
# Advanced: Create custom 3D figure and add multiple elements
|
|
194
|
+
fig, ax = vz.figure3d(title='Custom 3D Plot')
|
|
195
|
+
ax.plot_surface(X, Y, Z, cmap='plasma')
|
|
196
|
+
ax.contour(X, Y, Z, levels=10)
|
|
197
|
+
vz.show()
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
All 3D functions support full matplotlib customization via `**kwargs`.
|
|
201
|
+
|
|
202
|
+
## Installation
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Basic installation
|
|
206
|
+
pip install bottleviz
|
|
207
|
+
|
|
208
|
+
# With all optional backends
|
|
209
|
+
pip install bottleviz[all]
|
|
210
|
+
|
|
211
|
+
# Just pandas/numpy + matplotlib
|
|
212
|
+
pip install bottleviz
|
|
213
|
+
|
|
214
|
+
# For interactive plots (Plotly)
|
|
215
|
+
pip install bottleviz[plotly]
|
|
216
|
+
|
|
217
|
+
# For massive datasets (Datashader)
|
|
218
|
+
pip install bottleviz[datashader]
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Quick Start
|
|
222
|
+
|
|
223
|
+
```python
|
|
224
|
+
import bottleviz as vz
|
|
225
|
+
import pandas as pd
|
|
226
|
+
import numpy as np
|
|
227
|
+
|
|
228
|
+
# Create sample data
|
|
229
|
+
df = pd.DataFrame({
|
|
230
|
+
'x': np.random.randn(1000),
|
|
231
|
+
'y': np.random.randn(1000),
|
|
232
|
+
'category': np.random.choice(['A', 'B', 'C'], 1000),
|
|
233
|
+
'value': np.random.randint(0, 100, 1000)
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
# Simple plot - auto-detects scatter
|
|
237
|
+
vz.plot(df, x='x', y='y')
|
|
238
|
+
|
|
239
|
+
# Bar chart with categories
|
|
240
|
+
vz.plot(df, x='category', y='value', kind='bar')
|
|
241
|
+
|
|
242
|
+
# Histogram
|
|
243
|
+
vz.plot(df, kind='hist', x='value')
|
|
244
|
+
|
|
245
|
+
# Time series
|
|
246
|
+
dates = pd.date_range('2024-01-01', periods=100)
|
|
247
|
+
ts_df = pd.DataFrame({
|
|
248
|
+
'date': dates,
|
|
249
|
+
'price': np.random.randn(100).cumsum() + 100
|
|
250
|
+
})
|
|
251
|
+
vz.plot(ts_df, x='date', y='price') # Auto-detects line plot
|
|
252
|
+
|
|
253
|
+
# Change style
|
|
254
|
+
vz.set_style('dark')
|
|
255
|
+
vz.plot(df, x='x', y='y')
|
|
256
|
+
|
|
257
|
+
# Get suggestions
|
|
258
|
+
vz.suggest_plots(df)
|
|
259
|
+
|
|
260
|
+
# Quick dashboard
|
|
261
|
+
vz.visualize(df)
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## API Reference
|
|
265
|
+
|
|
266
|
+
### Main Functions
|
|
267
|
+
|
|
268
|
+
#### `vz.plot(data, x=None, y=None, kind=None, **kwargs)`
|
|
269
|
+
Core plotting function with smart defaults.
|
|
270
|
+
|
|
271
|
+
**Parameters:**
|
|
272
|
+
- `data`: DataFrame, Series, ndarray, list, or dict
|
|
273
|
+
- `x`: Column name for x-axis (optional)
|
|
274
|
+
- `y`: Column name(s) for y-axis (optional)
|
|
275
|
+
- `kind`: Plot type ('scatter', 'line', 'bar', 'hist', 'box', 'violin', 'heatmap', 'pie', 'area', 'kde', '3d', 'stem', 'errorbar', 'sankey', 'sunburst', 'treemap', 'network', 'candlestick')
|
|
276
|
+
- `**kwargs`: Additional arguments (title, xlabel, ylabel, etc.)
|
|
277
|
+
|
|
278
|
+
**Examples:**
|
|
279
|
+
```python
|
|
280
|
+
vz.plot(df, x='col1', y='col2') # Auto-detects scatter
|
|
281
|
+
vz.plot(df, x='col1', y='col2', kind='line') # Force line
|
|
282
|
+
vz.plot(df, kind='hist') # Histogram of all numeric columns
|
|
283
|
+
vz.plot(df, x='category', y='value', kind='bar') # Bar chart
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
#### `vz.quickplot(*args, **kwargs)`
|
|
287
|
+
Ultra-simple one-liner plotting.
|
|
288
|
+
|
|
289
|
+
```python
|
|
290
|
+
vz.quickplot([1,2,3,4,5]) # Line plot from list
|
|
291
|
+
vz.quickplot(x=[1,2,3], y=[4,5,6]) # Named lists
|
|
292
|
+
vz.quickplot(df) # Auto-visualize first two numeric columns
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
#### `vz.visualize(data, columns=None, plot_type='auto', max_plots=6, **kwargs)`
|
|
296
|
+
Create a multi-panel dashboard for exploratory analysis.
|
|
297
|
+
|
|
298
|
+
```python
|
|
299
|
+
vz.visualize(df) # Dashboard with all numeric columns
|
|
300
|
+
vz.visualize(df, columns=['x','y','z']) # Specific columns only
|
|
301
|
+
vz.visualize(df, plot_type='dist') # Distribution plots only
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
#### `vz.suggest_plots(data)`
|
|
305
|
+
Get recommendations for visualizations.
|
|
306
|
+
|
|
307
|
+
```python
|
|
308
|
+
recs = vz.suggest_plots(df)
|
|
309
|
+
print(recs)
|
|
310
|
+
# type x y rationale example_code
|
|
311
|
+
# 0 hist x None Distribution of 'x' - shows... vz.plot(df, x='x')
|
|
312
|
+
# 1 scatter x y Relationship between... vz.plot(df, x='x', y='y')
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
#### `vz.report(data, show_plots=False)`
|
|
316
|
+
Generate a comprehensive report.
|
|
317
|
+
|
|
318
|
+
```python
|
|
319
|
+
report = vz.report(df) # Text report
|
|
320
|
+
report = vz.report(df, show_plots=True) # Report + dashboard figure
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
#### `vz.explore(data, mode='auto')`
|
|
324
|
+
Smart exploratory data analysis.
|
|
325
|
+
|
|
326
|
+
```python
|
|
327
|
+
vz.explore(df) # Auto-choose best visualizations
|
|
328
|
+
vz.explore(df, mode='distribution') # Distribution plots only
|
|
329
|
+
vz.explore(df, mode='relationship') # Correlation plots
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Style Management
|
|
333
|
+
|
|
334
|
+
#### `vz.set_style(style)`
|
|
335
|
+
Set global visual style.
|
|
336
|
+
|
|
337
|
+
```python
|
|
338
|
+
vz.set_style('default') # Clean, modern default
|
|
339
|
+
vz.set_style('dark') # Dark theme
|
|
340
|
+
vz.set_style('minimal') # Minimal ink, maximum data
|
|
341
|
+
vz.set_style('publication')# Publication-ready
|
|
342
|
+
vz.set_style('seaborn') # Seaborn-compatible
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
#### `vz.available_styles()`
|
|
346
|
+
List available style presets.
|
|
347
|
+
|
|
348
|
+
```python
|
|
349
|
+
print(vz.available_styles())
|
|
350
|
+
# ['default', 'dark', 'minimal', 'publication', 'seaborn']
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
#### `vz.create_custom_style(name, **kwargs)`
|
|
354
|
+
Create your own style.
|
|
355
|
+
|
|
356
|
+
```python
|
|
357
|
+
vz.create_custom_style('my_style',
|
|
358
|
+
figure.figsize=(12, 8),
|
|
359
|
+
axes.titlesize=16,
|
|
360
|
+
axes.prop_cycle=plt.cycler('color', ['#FF0000', '#00FF00', '#0000FF'])
|
|
361
|
+
)
|
|
362
|
+
vz.set_style('my_style')
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Plot Types Supported
|
|
366
|
+
|
|
367
|
+
### Standard Plots
|
|
368
|
+
|
|
369
|
+
| Plot Type | Use Case | Auto-detected When |
|
|
370
|
+
|-----------|----------|-------------------|
|
|
371
|
+
| `scatter` | Relationship between two numeric variables | Two numeric columns provided |
|
|
372
|
+
| `line` | Time series or sequential data | Datetime index or sorted x-axis |
|
|
373
|
+
| `bar` | Categorical comparisons | Categorical x with numeric y |
|
|
374
|
+
| `hist` | Distribution of single variable | Single numeric column |
|
|
375
|
+
| `box` | Distribution with outliers | Box plot recommended |
|
|
376
|
+
| `violin` | Detailed distribution shape | Violin plot recommended |
|
|
377
|
+
| `kde` | Smooth density estimate | KDE recommended |
|
|
378
|
+
| `area` | Cumulative totals | Area plot specified |
|
|
379
|
+
| `heatmap` | Correlation matrix | Matrix data or 3+ numeric columns |
|
|
380
|
+
| `pie` | Proportional breakdown | Single categorical column with ≤6 unique values |
|
|
381
|
+
| `stem` | Discrete data points with stems | Stem plot specified |
|
|
382
|
+
| `errorbar` | Data with error margins | Error values provided |
|
|
383
|
+
| `candlestick` | Financial OHLC data | Open, high, low, close columns |
|
|
384
|
+
|
|
385
|
+
### Advanced Visualizations
|
|
386
|
+
|
|
387
|
+
| Plot Type | Use Case | Requirements |
|
|
388
|
+
|-----------|----------|--------------|
|
|
389
|
+
| `sankey` | Flow between stages/categories | Multi-stage path or source-target pairs; requires `networkx` |
|
|
390
|
+
| `sunburst` | Hierarchical radial layout | Hierarchical path with value; optional `squarify` |
|
|
391
|
+
| `treemap` | Hierarchical rectangular layout | Hierarchical path with value; requires `squarify` |
|
|
392
|
+
| `network` | Graph relationships | Edge list (source, target); requires `networkx` |
|
|
393
|
+
|
|
394
|
+
### 3D Visualizations
|
|
395
|
+
|
|
396
|
+
| Plot Type | Use Case | Data Format |
|
|
397
|
+
|-----------|----------|-------------|
|
|
398
|
+
| `plot_3d_surface` | Continuous surface (points connected as planes) | 2D meshgrid arrays (X, Y, Z) |
|
|
399
|
+
| `plot_3d_wireframe` | Wireframe mesh showing grid structure | 2D meshgrid arrays (X, Y, Z) |
|
|
400
|
+
| `plot_3d_trisurf` | Triangular surface for scattered data | 1D arrays (x, y, z) - triangulated automatically |
|
|
401
|
+
| `plot_3d_contour` | 3D contour lines | 2D meshgrid arrays (X, Y, Z) |
|
|
402
|
+
| `plot_3d_contourf` | Filled 3D contours | 2D meshgrid arrays (X, Y, Z) |
|
|
403
|
+
| `plot_3d_quiver` | 3D vector field (arrows) | Grid coordinates (X, Y, Z) and vector components (U, V, W) |
|
|
404
|
+
| `plot_3d_stem` | 3D stem plots | 1D arrays (x, y, z) |
|
|
405
|
+
| `plot_3d_bar` | 3D bar chart | Positions (x, y, z) and dimensions (dx, dy, dz) |
|
|
406
|
+
| `plot_3d_voxels` | 3D volume/cube rendering | 3D boolean or scalar array |
|
|
407
|
+
| `figure3d` | Create empty 3D figure for custom plotting | Returns (fig, ax) for manual plotting |
|
|
408
|
+
|
|
409
|
+
All 3D functions provide full access to matplotlib's 3D API via `**kwargs`.
|
|
410
|
+
|
|
411
|
+
## Solving Gaps in Existing Libraries
|
|
412
|
+
|
|
413
|
+
### vs Matplotlib
|
|
414
|
+
- **Simplicity**: No more verbose `fig, ax = plt.subplots()` boilerplate
|
|
415
|
+
- **Smarter defaults**: Beautiful plots automatically
|
|
416
|
+
- **Type inference**: No need to specify plot type manually
|
|
417
|
+
|
|
418
|
+
### vs Seaborn
|
|
419
|
+
- **Performance**: Better optimization for large datasets
|
|
420
|
+
- **Consistency**: One function for all plot types
|
|
421
|
+
- **Flexibility**: Works with numpy arrays directly
|
|
422
|
+
|
|
423
|
+
### vs Plotly
|
|
424
|
+
- **Lightweight**: Pure Python core, no JavaScript needed
|
|
425
|
+
- **Static quality**: Publication-ready out of the box
|
|
426
|
+
- **Easier deployment**: No browser dependencies
|
|
427
|
+
|
|
428
|
+
## Advanced Features
|
|
429
|
+
|
|
430
|
+
### Large Dataset Optimization
|
|
431
|
+
```python
|
|
432
|
+
# Automatic downsampling for >10k points
|
|
433
|
+
vz.plot(huge_df) # Smooth even with 1M rows
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Smart Color Palettes
|
|
437
|
+
```python
|
|
438
|
+
# Automatically colorblind-friendly
|
|
439
|
+
vz.plot(df, x='cat', y='val', kind='bar') # Beautiful colors
|
|
440
|
+
|
|
441
|
+
# Custom palette
|
|
442
|
+
vz.plot(df, x='cat', y='val', kind='bar', palette='pastel')
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
### Automatic Subplot Layout
|
|
446
|
+
```python
|
|
447
|
+
# Automatically arranges subplots
|
|
448
|
+
vz.visualize(df, max_plots=6) # Smart 2x3 layout
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### Pandas/Polars Integration
|
|
452
|
+
```python
|
|
453
|
+
# Works with many data structures
|
|
454
|
+
vz.plot(df) # pandas DataFrame
|
|
455
|
+
vz.plot(pl.DataFrame(...)) # polars DataFrame
|
|
456
|
+
vz.plot(np_array) # NumPy array
|
|
457
|
+
vz.plot([1,2,3,4,5]) # Python list
|
|
458
|
+
vz.plot({'x': [...], 'y': [...]}) # Dictionary
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
## Limitations and Future Work
|
|
462
|
+
|
|
463
|
+
**Current limitations:**
|
|
464
|
+
- Only matplotlib backend implemented (Plotly backend planned)
|
|
465
|
+
- Advanced charts (Sankey, Sunburst, Treemap, Network, Candlestick) require optional dependencies
|
|
466
|
+
- 3D visualizations use matplotlib's mplot3d (limited interactivity compared to Plotly)
|
|
467
|
+
|
|
468
|
+
**Planned features:**
|
|
469
|
+
- [ ] Plotly interactive backend with enhanced 3D
|
|
470
|
+
- [ ] Bokeh backend
|
|
471
|
+
- [ ] GPU acceleration with CuPy
|
|
472
|
+
- [ ] Map/geographic visualizations
|
|
473
|
+
- [ ] Animation support
|
|
474
|
+
- [ ] Export to HTML with interactivity
|
|
475
|
+
- [ ] Graphviz layout for network graphs
|
|
476
|
+
|
|
477
|
+
## Requirements
|
|
478
|
+
|
|
479
|
+
- Python >= 3.8
|
|
480
|
+
- NumPy >= 1.18.0
|
|
481
|
+
- Pandas >= 1.0.0
|
|
482
|
+
- Matplotlib >= 3.0.0
|
|
483
|
+
|
|
484
|
+
Optional:
|
|
485
|
+
- plotly >= 5.0.0 (for interactive plots)
|
|
486
|
+
- datashader >= 0.13.0 (for massive datasets)
|
|
487
|
+
- networkx (for network graphs and Sankey diagrams)
|
|
488
|
+
- squarify (for treemaps)
|
|
489
|
+
- polars (alternative to pandas)
|
|
490
|
+
|
|
491
|
+
## Contributing
|
|
492
|
+
|
|
493
|
+
We welcome contributions! Please see our contributing guide in the repository.
|
|
494
|
+
|
|
495
|
+
## License
|
|
496
|
+
|
|
497
|
+
MIT License - see LICENSE file for details.
|
|
498
|
+
|
|
499
|
+
## Examples Gallery
|
|
500
|
+
|
|
501
|
+
More examples available in the `examples/` directory:
|
|
502
|
+
|
|
503
|
+
1. **Basic Plots**: Line, scatter, bar, histogram (`demo.py`, `example.py`)
|
|
504
|
+
2. **Statistical**: Box, violin, KDE
|
|
505
|
+
3. **Compositional**: Pie, area, stacked charts
|
|
506
|
+
4. **Multivariate**: Heatmap, pair plots, 3D
|
|
507
|
+
5. **Time Series**: Date handling, rolling windows
|
|
508
|
+
6. **Large Data**: Downsampling, datashader
|
|
509
|
+
7. **Styling**: Themes, custom palettes, publication tips
|
|
510
|
+
8. **Advanced**: Sankey, Sunburst, Treemap, Network, Candlestick
|
|
511
|
+
9. **3D Visualizations**:
|
|
512
|
+
- `all_3d_plots.py` - Comprehensive demo of all 10+ 3D plot types (surface, wireframe, trisurf, contour, quiver, stem, bar3d, voxels)
|
|
513
|
+
- `array_slices_3d.py` - Advanced 3D array slices with intersecting planes
|
|
514
|
+
- `demo_show_close.py` - Cone surface plot with show/close functions
|
|
515
|
+
|
|
516
|
+
Run examples:
|
|
517
|
+
```bash
|
|
518
|
+
python -m bottleviz.examples
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
## Citation
|
|
522
|
+
|
|
523
|
+
If you use BottleViz in your research, please cite:
|
|
524
|
+
|
|
525
|
+
```bibtex
|
|
526
|
+
@software{bottleviz2024,
|
|
527
|
+
author = {{BottleViz Team}},
|
|
528
|
+
title = {{BottleViz: A Modern Python Visualization Library}},
|
|
529
|
+
year = {2024},
|
|
530
|
+
url = {https://github.com/bottleviz/bottleviz}
|
|
531
|
+
}
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
---
|
|
535
|
+
|
|
536
|
+
**Made with ❤️ for data scientists, analysts, and engineers who believe visualization should be simple and beautiful.**
|