mirror of
https://github.com/K-Dense-AI/scientific-agent-skills.git
synced 2026-12-06 19:44:01 +08:00
Update anndata skill documentation to version 1.1, enhancing compatibility notes and installation instructions. Introduce experimental APIs for lazy loading and concatenation, and clarify usage of deprecated methods. Update best practices for I/O operations and metadata handling.
This commit is contained in:
1 parent
b2a969eb56
commit
b24a631e44
47 files changed
+798
-478
No files matched your search
+33
-12
@@ -1,9 +1,14 @@
|
||||
---
|
||||
name: matplotlib
|
||||
description: Low-level plotting library for full customization. Use when you need fine-grained control over every plot element, creating novel plot types, or integrating with specific scientific workflows. Export to PNG/PDF/SVG for publication. For quick statistical plots use seaborn; for interactive plots use plotly; for publication-ready multi-panel figures with journal styling, use scientific-visualization.
|
||||
allowed-tools:
|
||||
- Read
|
||||
- Write
|
||||
- Bash
|
||||
license: https://github.com/matplotlib/matplotlib/tree/main/LICENSE
|
||||
compatibility: Requires Python 3.10+ and Matplotlib 3.10.x. Use `uv add matplotlib` in projects; interactive Jupyter widgets require `ipympl`.
|
||||
metadata:
|
||||
version: "1.0"
|
||||
version: "1.1"
|
||||
skill-author: K-Dense Inc.
|
||||
---
|
||||
|
||||
@@ -25,6 +30,24 @@ This skill should be used when:
|
||||
- Working with 3D visualizations
|
||||
- Integrating plots into Jupyter notebooks or GUI applications
|
||||
|
||||
## Setup
|
||||
|
||||
For project work, install Matplotlib with uv:
|
||||
|
||||
```bash
|
||||
uv add matplotlib
|
||||
```
|
||||
|
||||
For notebook interactivity:
|
||||
|
||||
```bash
|
||||
uv add matplotlib ipympl
|
||||
```
|
||||
|
||||
Then enable the widget backend in Jupyter with `%matplotlib widget` or `%matplotlib ipympl`.
|
||||
|
||||
Matplotlib 3.10 requires Python 3.10+ and NumPy 1.23+. Non-interactive file output works through backends such as Agg, PDF, and SVG. For GUI windows, Matplotlib auto-selects an available backend; if `TkAgg` fails in a uv-managed Python, update uv and Python builds with `uv self update` and `uv python upgrade --reinstall`, or install a Qt backend with `uv add pyside6`.
|
||||
|
||||
## Core Concepts
|
||||
|
||||
### The Matplotlib Hierarchy
|
||||
@@ -89,7 +112,7 @@ ax.legend()
|
||||
ax.grid(True, alpha=0.3)
|
||||
|
||||
# Save and/or display
|
||||
plt.savefig('plot.png', dpi=300, bbox_inches='tight')
|
||||
fig.savefig('plot.png', dpi=300, bbox_inches='tight')
|
||||
plt.show()
|
||||
```
|
||||
|
||||
@@ -159,7 +182,7 @@ ax.clabel(contour, inline=True, fontsize=8)
|
||||
|
||||
**Box plots** - Statistical distributions
|
||||
```python
|
||||
ax.boxplot([data1, data2, data3], labels=['A', 'B', 'C'])
|
||||
ax.boxplot([data1, data2, data3], tick_labels=['A', 'B', 'C'])
|
||||
```
|
||||
|
||||
**Violin plots** - Distribution densities
|
||||
@@ -209,14 +232,14 @@ For detailed styling options and colormap guidelines, see `references/styling_gu
|
||||
**Export to various formats:**
|
||||
```python
|
||||
# High-resolution PNG for presentations/papers
|
||||
plt.savefig('figure.png', dpi=300, bbox_inches='tight', facecolor='white')
|
||||
fig.savefig('figure.png', dpi=300, bbox_inches='tight', facecolor='white')
|
||||
|
||||
# Vector format for publications (scalable)
|
||||
plt.savefig('figure.pdf', bbox_inches='tight')
|
||||
plt.savefig('figure.svg', bbox_inches='tight')
|
||||
fig.savefig('figure.pdf', bbox_inches='tight')
|
||||
fig.savefig('figure.svg', bbox_inches='tight')
|
||||
|
||||
# Transparent background
|
||||
plt.savefig('figure.png', dpi=300, bbox_inches='tight', transparent=True)
|
||||
fig.savefig('figure.png', dpi=300, bbox_inches='tight', transparent=True)
|
||||
```
|
||||
|
||||
**Important parameters:**
|
||||
@@ -228,8 +251,6 @@ plt.savefig('figure.png', dpi=300, bbox_inches='tight', transparent=True)
|
||||
### 6. Working with 3D Plots
|
||||
|
||||
```python
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
|
||||
fig = plt.figure(figsize=(10, 8))
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
|
||||
@@ -303,7 +324,7 @@ def create_analysis_plot(data, title):
|
||||
|
||||
# Use the function
|
||||
fig, ax = create_analysis_plot(my_data, 'My Analysis')
|
||||
plt.savefig('analysis.png', dpi=300, bbox_inches='tight')
|
||||
fig.savefig('analysis.png', dpi=300, bbox_inches='tight')
|
||||
```
|
||||
|
||||
## Quick Reference Scripts
|
||||
@@ -315,7 +336,7 @@ Template script demonstrating various plot types with best practices. Use this a
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
python scripts/plot_template.py
|
||||
uv run python scripts/plot_template.py
|
||||
```
|
||||
|
||||
### `style_configurator.py`
|
||||
@@ -323,7 +344,7 @@ Interactive utility to configure matplotlib style preferences and generate custo
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
python scripts/style_configurator.py
|
||||
uv run python scripts/style_configurator.py
|
||||
```
|
||||
|
||||
## Detailed References
|
||||
|
||||
@@ -56,7 +56,7 @@ ax = fig.add_subplot(111) # Alternative method
|
||||
|
||||
**Statistical plots:**
|
||||
- `ax.hist(data, bins=10, density=False)` - Histogram
|
||||
- `ax.boxplot(data, labels=None)` - Box plot
|
||||
- `ax.boxplot(data, tick_labels=None, orientation='vertical')` - Box plot
|
||||
- `ax.violinplot(data)` - Violin plot
|
||||
|
||||
**2D plots:**
|
||||
@@ -88,7 +88,7 @@ ax = fig.add_subplot(111) # Alternative method
|
||||
|
||||
**Ticks:**
|
||||
- `ax.set_xticks(positions)` - Set x-tick positions
|
||||
- `ax.set_xticklabels(labels)` - Set x-tick labels
|
||||
- `ax.set_xticks(positions, labels)` - Set x-tick positions and labels together
|
||||
- `ax.tick_params(axis='both', labelsize=10)` - Customize tick appearance
|
||||
|
||||
**Grid and spines:**
|
||||
@@ -299,8 +299,6 @@ ax5 = fig.add_subplot(gs[2, 2]) # Bottom row, right column
|
||||
## 3D Plotting
|
||||
|
||||
```python
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
|
||||
@@ -399,8 +397,7 @@ fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True)
|
||||
ax2 = ax1.twinx()
|
||||
|
||||
# Remove tick labels
|
||||
ax.set_xticklabels([])
|
||||
ax.set_yticklabels([])
|
||||
ax.tick_params(labelbottom=False, labelleft=False)
|
||||
|
||||
# Scientific notation
|
||||
ax.ticklabel_format(style='scientific', axis='y', scilimits=(0,0))
|
||||
|
||||
@@ -80,7 +80,8 @@ plt.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.15)
|
||||
plt.savefig('figure.png', bbox_inches='tight')
|
||||
|
||||
# Solution 5: Rotate long tick labels
|
||||
ax.set_xticklabels(labels, rotation=45, ha='right')
|
||||
ax.set_xticks(positions, labels)
|
||||
plt.setp(ax.get_xticklabels(), rotation=45, ha='right')
|
||||
```
|
||||
|
||||
### Issue: Colorbar Affects Subplot Size
|
||||
@@ -198,9 +199,9 @@ ax.hexbin(x, y, gridsize=50, cmap='viridis')
|
||||
from matplotlib.font_manager import findfont, FontProperties
|
||||
print(findfont(FontProperties(family='sans-serif')))
|
||||
|
||||
# Solution 2: Rebuild font cache
|
||||
import matplotlib.font_manager
|
||||
matplotlib.font_manager._rebuild()
|
||||
# Solution 2: Check Matplotlib's cache directory, then restart Python
|
||||
import matplotlib
|
||||
print(matplotlib.get_cachedir())
|
||||
|
||||
# Solution 3: Suppress warnings
|
||||
import warnings
|
||||
@@ -434,8 +435,6 @@ scatter = ax.scatter(x, y, z, c=z, cmap='viridis')
|
||||
|
||||
**Solution:**
|
||||
```python
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
|
||||
fig = plt.figure(figsize=(10, 8))
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
ax.plot_surface(X, Y, Z)
|
||||
|
||||
@@ -91,8 +91,7 @@ width = 0.35
|
||||
|
||||
ax.bar(x - width/2, values1, width, label='Group 1')
|
||||
ax.bar(x + width/2, values2, width, label='Group 2')
|
||||
ax.set_xticks(x)
|
||||
ax.set_xticklabels(categories)
|
||||
ax.set_xticks(x, categories)
|
||||
ax.legend()
|
||||
```
|
||||
|
||||
@@ -168,15 +167,16 @@ plt.colorbar(h[3], ax=ax, label='Counts')
|
||||
### Box Plot
|
||||
```python
|
||||
ax.boxplot([data1, data2, data3],
|
||||
labels=['Group A', 'Group B', 'Group C'],
|
||||
tick_labels=['Group A', 'Group B', 'Group C'],
|
||||
showmeans=True, meanline=True)
|
||||
ax.set_ylabel('Values')
|
||||
```
|
||||
|
||||
### Horizontal Box Plot
|
||||
```python
|
||||
ax.boxplot([data1, data2, data3], vert=False,
|
||||
labels=['Group A', 'Group B', 'Group C'])
|
||||
ax.boxplot([data1, data2, data3],
|
||||
orientation='horizontal',
|
||||
tick_labels=['Group A', 'Group B', 'Group C'])
|
||||
ax.set_xlabel('Values')
|
||||
```
|
||||
|
||||
@@ -185,8 +185,7 @@ ax.set_xlabel('Values')
|
||||
parts = ax.violinplot([data1, data2, data3],
|
||||
positions=[1, 2, 3],
|
||||
showmeans=True, showmedians=True)
|
||||
ax.set_xticks([1, 2, 3])
|
||||
ax.set_xticklabels(['Group A', 'Group B', 'Group C'])
|
||||
ax.set_xticks([1, 2, 3], ['Group A', 'Group B', 'Group C'])
|
||||
```
|
||||
|
||||
## 6. Heatmaps
|
||||
@@ -220,10 +219,8 @@ im = ax.imshow(corr, cmap='RdBu_r', vmin=-1, vmax=1)
|
||||
plt.colorbar(im, ax=ax, label='Correlation')
|
||||
|
||||
# Set tick labels
|
||||
ax.set_xticks(range(len(corr)))
|
||||
ax.set_yticks(range(len(corr)))
|
||||
ax.set_xticklabels(corr.columns, rotation=45, ha='right')
|
||||
ax.set_yticklabels(corr.columns)
|
||||
ax.set_xticks(range(len(corr)), corr.columns, rotation=45, ha='right')
|
||||
ax.set_yticks(range(len(corr)), corr.columns)
|
||||
```
|
||||
|
||||
## 7. Contour Plots
|
||||
@@ -304,8 +301,7 @@ angles_closed = np.concatenate((angles, [angles[0]]))
|
||||
ax = plt.subplot(111, projection='polar')
|
||||
ax.plot(angles_closed, values_closed, 'o-', linewidth=2)
|
||||
ax.fill(angles_closed, values_closed, alpha=0.25)
|
||||
ax.set_xticks(angles)
|
||||
ax.set_xticklabels(categories)
|
||||
ax.set_xticks(angles, categories)
|
||||
```
|
||||
|
||||
## 10. Stream and Quiver Plots
|
||||
@@ -355,8 +351,6 @@ ax.legend()
|
||||
|
||||
### 3D Scatter
|
||||
```python
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
|
||||
fig = plt.figure(figsize=(10, 8))
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
scatter = ax.scatter(x, y, z, c=colors, cmap='viridis',
|
||||
@@ -433,8 +427,7 @@ ax.broken_barh([(10, 20), (50, 50), (120, 30)], (20, 9),
|
||||
ax.set_ylim(5, 35)
|
||||
ax.set_xlim(0, 200)
|
||||
ax.set_xlabel('Time')
|
||||
ax.set_yticks([15, 25])
|
||||
ax.set_yticklabels(['Task 1', 'Task 2'])
|
||||
ax.set_yticks([15, 25], ['Task 1', 'Task 2'])
|
||||
```
|
||||
|
||||
## 14. Time Series Plots
|
||||
|
||||
@@ -50,7 +50,9 @@ Best for categorical/nominal data without inherent ordering.
|
||||
|
||||
**Usage:**
|
||||
```python
|
||||
colors = plt.cm.tab10(np.linspace(0, 1, n_categories))
|
||||
import matplotlib as mpl
|
||||
|
||||
colors = mpl.colormaps['tab10'](np.linspace(0, 1, n_categories))
|
||||
for i, category in enumerate(categories):
|
||||
ax.plot(x, y[i], color=colors[i], label=category)
|
||||
```
|
||||
@@ -76,6 +78,7 @@ Best for cyclic data (e.g., phase, angle).
|
||||
|
||||
```python
|
||||
from matplotlib.colors import LinearSegmentedColormap
|
||||
import matplotlib as mpl
|
||||
|
||||
# From color list
|
||||
colors = ['blue', 'white', 'red']
|
||||
@@ -88,15 +91,19 @@ cmap = LinearSegmentedColormap.from_list('custom', colors)
|
||||
|
||||
# Use the custom colormap
|
||||
ax.imshow(data, cmap=cmap)
|
||||
|
||||
# Optionally register it by name for reuse
|
||||
mpl.colormaps.register(cmap, name='custom')
|
||||
```
|
||||
|
||||
### Discrete Colormaps
|
||||
|
||||
```python
|
||||
import matplotlib.colors as mcolors
|
||||
import matplotlib as mpl
|
||||
|
||||
# Create discrete colormap from continuous
|
||||
cmap = plt.cm.viridis
|
||||
cmap = mpl.colormaps['viridis']
|
||||
bounds = np.linspace(0, 10, 11)
|
||||
norm = mcolors.BoundaryNorm(bounds, cmap.N)
|
||||
im = ax.imshow(data, cmap=cmap, norm=norm)
|
||||
@@ -284,8 +291,10 @@ plt.rcParams['savefig.transparent'] = False
|
||||
### Named Color Sets
|
||||
|
||||
```python
|
||||
import matplotlib as mpl
|
||||
|
||||
# Tableau colors
|
||||
tableau_colors = plt.cm.tab10.colors
|
||||
tableau_colors = mpl.colormaps['tab10'].colors
|
||||
|
||||
# CSS4 colors (subset)
|
||||
css_colors = ['steelblue', 'coral', 'teal', 'goldenrod', 'crimson']
|
||||
@@ -309,9 +318,11 @@ plt.rcParams['axes.prop_cycle'] = cycler(color=colors) + cycler(linestyle=['-',
|
||||
### Palette Generation
|
||||
|
||||
```python
|
||||
import matplotlib as mpl
|
||||
|
||||
# Evenly spaced colors from colormap
|
||||
n_colors = 5
|
||||
colors = plt.cm.viridis(np.linspace(0, 1, n_colors))
|
||||
colors = mpl.colormaps['viridis'](np.linspace(0, 1, n_colors))
|
||||
|
||||
# Use in plot
|
||||
for i, (x, y) in enumerate(data):
|
||||
|
||||
@@ -13,6 +13,7 @@ Plot types:
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import matplotlib as mpl
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib.gridspec import GridSpec
|
||||
import argparse
|
||||
@@ -63,6 +64,7 @@ def generate_sample_data():
|
||||
|
||||
def create_line_plot(data, ax=None):
|
||||
"""Create line plot with best practices."""
|
||||
created_fig = ax is None
|
||||
if ax is None:
|
||||
fig, ax = plt.subplots(figsize=(10, 6), constrained_layout=True)
|
||||
|
||||
@@ -80,13 +82,14 @@ def create_line_plot(data, ax=None):
|
||||
ax.spines['top'].set_visible(False)
|
||||
ax.spines['right'].set_visible(False)
|
||||
|
||||
if ax is None:
|
||||
if created_fig:
|
||||
return fig
|
||||
return ax
|
||||
|
||||
|
||||
def create_scatter_plot(data, ax=None):
|
||||
"""Create scatter plot with color and size variations."""
|
||||
created_fig = ax is None
|
||||
if ax is None:
|
||||
fig, ax = plt.subplots(figsize=(10, 6), constrained_layout=True)
|
||||
|
||||
@@ -107,13 +110,14 @@ def create_scatter_plot(data, ax=None):
|
||||
cbar = plt.colorbar(scatter, ax=ax)
|
||||
cbar.set_label('Distance from origin')
|
||||
|
||||
if ax is None:
|
||||
if created_fig:
|
||||
return fig
|
||||
return ax
|
||||
|
||||
|
||||
def create_bar_chart(data, ax=None):
|
||||
"""Create bar chart with error bars and styling."""
|
||||
created_fig = ax is None
|
||||
if ax is None:
|
||||
fig, ax = plt.subplots(figsize=(10, 6), constrained_layout=True)
|
||||
|
||||
@@ -125,28 +129,28 @@ def create_bar_chart(data, ax=None):
|
||||
capsize=5, alpha=0.8)
|
||||
|
||||
# Color bars by value
|
||||
colors = plt.cm.viridis(data['bar_values'] / data['bar_values'].max())
|
||||
colors = mpl.colormaps['viridis'](data['bar_values'] / data['bar_values'].max())
|
||||
for bar, color in zip(bars, colors):
|
||||
bar.set_facecolor(color)
|
||||
|
||||
ax.set_xlabel('Category')
|
||||
ax.set_ylabel('Values')
|
||||
ax.set_title('Bar Chart Example')
|
||||
ax.set_xticks(x_pos)
|
||||
ax.set_xticklabels(data['categories'])
|
||||
ax.set_xticks(x_pos, data['categories'])
|
||||
ax.grid(True, axis='y', alpha=0.3, linestyle='--')
|
||||
|
||||
# Remove top and right spines
|
||||
ax.spines['top'].set_visible(False)
|
||||
ax.spines['right'].set_visible(False)
|
||||
|
||||
if ax is None:
|
||||
if created_fig:
|
||||
return fig
|
||||
return ax
|
||||
|
||||
|
||||
def create_histogram(data, ax=None):
|
||||
"""Create histogram with density overlay."""
|
||||
created_fig = ax is None
|
||||
if ax is None:
|
||||
fig, ax = plt.subplots(figsize=(10, 6), constrained_layout=True)
|
||||
|
||||
@@ -166,13 +170,14 @@ def create_histogram(data, ax=None):
|
||||
ax.legend()
|
||||
ax.grid(True, axis='y', alpha=0.3, linestyle='--')
|
||||
|
||||
if ax is None:
|
||||
if created_fig:
|
||||
return fig
|
||||
return ax
|
||||
|
||||
|
||||
def create_heatmap(data, ax=None):
|
||||
"""Create heatmap with colorbar and annotations."""
|
||||
created_fig = ax is None
|
||||
if ax is None:
|
||||
fig, ax = plt.subplots(figsize=(10, 8), constrained_layout=True)
|
||||
|
||||
@@ -193,13 +198,14 @@ def create_heatmap(data, ax=None):
|
||||
ax.set_ylabel('Y Index')
|
||||
ax.set_title('Heatmap Example')
|
||||
|
||||
if ax is None:
|
||||
if created_fig:
|
||||
return fig
|
||||
return ax
|
||||
|
||||
|
||||
def create_contour_plot(data, ax=None):
|
||||
"""Create contour plot with filled contours and labels."""
|
||||
created_fig = ax is None
|
||||
if ax is None:
|
||||
fig, ax = plt.subplots(figsize=(10, 8), constrained_layout=True)
|
||||
|
||||
@@ -223,37 +229,39 @@ def create_contour_plot(data, ax=None):
|
||||
ax.set_title('Contour Plot Example')
|
||||
ax.set_aspect('equal')
|
||||
|
||||
if ax is None:
|
||||
if created_fig:
|
||||
return fig
|
||||
return ax
|
||||
|
||||
|
||||
def create_box_plot(data, ax=None):
|
||||
"""Create box plot comparing distributions."""
|
||||
created_fig = ax is None
|
||||
if ax is None:
|
||||
fig, ax = plt.subplots(figsize=(10, 6), constrained_layout=True)
|
||||
|
||||
# Generate multiple distributions
|
||||
box_data = [np.random.normal(0, std, 100) for std in range(1, 5)]
|
||||
|
||||
bp = ax.boxplot(box_data, labels=['Group 1', 'Group 2', 'Group 3', 'Group 4'],
|
||||
patch_artist=True, showmeans=True,
|
||||
boxprops=dict(facecolor='lightblue', edgecolor='black'),
|
||||
medianprops=dict(color='red', linewidth=2),
|
||||
meanprops=dict(marker='D', markerfacecolor='green', markersize=8))
|
||||
ax.boxplot(box_data, tick_labels=['Group 1', 'Group 2', 'Group 3', 'Group 4'],
|
||||
patch_artist=True, showmeans=True,
|
||||
boxprops=dict(facecolor='lightblue', edgecolor='black'),
|
||||
medianprops=dict(color='red', linewidth=2),
|
||||
meanprops=dict(marker='D', markerfacecolor='green', markersize=8))
|
||||
|
||||
ax.set_xlabel('Groups')
|
||||
ax.set_ylabel('Values')
|
||||
ax.set_title('Box Plot Example')
|
||||
ax.grid(True, axis='y', alpha=0.3, linestyle='--')
|
||||
|
||||
if ax is None:
|
||||
if created_fig:
|
||||
return fig
|
||||
return ax
|
||||
|
||||
|
||||
def create_violin_plot(data, ax=None):
|
||||
"""Create violin plot showing distribution shapes."""
|
||||
created_fig = ax is None
|
||||
if ax is None:
|
||||
fig, ax = plt.subplots(figsize=(10, 6), constrained_layout=True)
|
||||
|
||||
@@ -272,19 +280,16 @@ def create_violin_plot(data, ax=None):
|
||||
ax.set_xlabel('Groups')
|
||||
ax.set_ylabel('Values')
|
||||
ax.set_title('Violin Plot Example')
|
||||
ax.set_xticks(range(1, 5))
|
||||
ax.set_xticklabels(['Group 1', 'Group 2', 'Group 3', 'Group 4'])
|
||||
ax.set_xticks(range(1, 5), ['Group 1', 'Group 2', 'Group 3', 'Group 4'])
|
||||
ax.grid(True, axis='y', alpha=0.3, linestyle='--')
|
||||
|
||||
if ax is None:
|
||||
if created_fig:
|
||||
return fig
|
||||
return ax
|
||||
|
||||
|
||||
def create_3d_plot():
|
||||
"""Create 3D surface plot."""
|
||||
from mpl_toolkits.mplot3d import Axes3D
|
||||
|
||||
fig = plt.figure(figsize=(12, 9))
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@ Presets:
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import matplotlib as mpl
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib.gridspec import GridSpec
|
||||
import argparse
|
||||
import os
|
||||
|
||||
|
||||
# Predefined style presets
|
||||
@@ -166,7 +166,7 @@ def create_style_preview(style_dict=None):
|
||||
bars = ax3.bar(data['categories'], data['bar_values'],
|
||||
edgecolor='black', linewidth=1)
|
||||
# Color bars with gradient
|
||||
colors = plt.cm.viridis(np.linspace(0.2, 0.8, len(bars)))
|
||||
colors = mpl.colormaps['viridis'](np.linspace(0.2, 0.8, len(bars)))
|
||||
for bar, color in zip(bars, colors):
|
||||
bar.set_facecolor(color)
|
||||
ax3.set_xlabel('Categories')
|
||||
@@ -299,7 +299,8 @@ def interactive_mode():
|
||||
print(" 5. Color scheme")
|
||||
print(" 6. Done, show preview")
|
||||
|
||||
while True:
|
||||
max_customization_steps = 20
|
||||
for _ in range(max_customization_steps):
|
||||
choice = input("\nSelect option (1-6): ").strip()
|
||||
|
||||
if choice == '1':
|
||||
@@ -332,6 +333,8 @@ def interactive_mode():
|
||||
|
||||
elif choice == '6':
|
||||
break
|
||||
else:
|
||||
print("\nReached customization step limit; showing preview with current settings.")
|
||||
|
||||
return style_dict
|
||||
|
||||
|
||||
Reference in new issue
Block a user