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:
Timothy Kassis committed 2026-06-07 14:59:51 -07:00
1 parent b2a969eb56
commit b24a631e44
47 files changed
+798 -478

No files matched your search

@@ -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)
+10 -17
View File
@@ -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
+15 -4
View File
@@ -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):