Skip to content

Commit f51071a

Browse files
dshkolclaude
andcommitted
Fix visualization rendering with proper Sphinx/MyST-NB configuration
Critical fixes to make plots display correctly on Read the Docs: 1. **Fixed Sphinx Gallery boolean** (conf.py line 111) - Changed 'plot_gallery': 'True' → 'plot_gallery': True - String 'True' was causing issues with Sphinx Gallery logic 2. **Added MyST-NB render priority** (conf.py lines 91-93) - Explicitly prioritize PNG/SVG image rendering - Ensures matplotlib outputs are captured correctly 3. **Explicitly return figures in tutorial** (working_with_geometry.md) - Added `fig` as last statement in 4 plot cells - MyST-NB needs explicit figure returns to capture plots - Now generates 5 images (was 3, then 0 on RTD) Verified locally: All visualizations render correctly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent cf17f13 commit f51071a

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

docs/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888

8989
nb_execution_mode = "auto"
9090
nb_execution_timeout = 300
91+
nb_render_priority = {
92+
"html": ("image/png", "image/svg+xml", "text/html"),
93+
}
9194

9295
# Sphinx Gallery configuration
9396
sphinx_gallery_conf = {
@@ -108,7 +111,7 @@
108111
"%matplotlib inline"
109112
),
110113
# Execute examples on RTD to generate visualizations
111-
'plot_gallery': 'True',
114+
'plot_gallery': True,
112115
}
113116

114117
# Intersphinx mapping

docs/tutorials/working_with_geometry.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ ax.set_title('Population by Municipality\nVancouver CMA, 2021', fontsize=16)
129129
ax.axis('off') # Remove axes for cleaner look
130130
131131
plt.tight_layout()
132+
fig # Display the figure
132133
```
133134

134135
## Multi-Variable Mapping
@@ -166,6 +167,7 @@ ax2.axis('off')
166167
167168
plt.suptitle('Vancouver CMA: Population vs Income', fontsize=16, y=1.02)
168169
plt.tight_layout()
170+
fig # Display the figure
169171
```
170172

171173
## Working with Different Geographic Levels
@@ -226,6 +228,7 @@ try:
226228
boundaries.plot(ax=ax, edgecolor='blue', facecolor='lightblue', alpha=0.7)
227229
ax.set_title('Vancouver CMA Municipal Boundaries')
228230
ax.axis('off')
231+
fig # Display the figure
229232
230233
except Exception as e:
231234
print(f"Error getting boundaries: {e}")
@@ -235,6 +238,7 @@ except Exception as e:
235238
vancouver_data.boundary.plot(ax=ax, color='blue', linewidth=2)
236239
ax.set_title('Sample Municipal Boundaries')
237240
ax.axis('off')
241+
fig # Display the figure
238242
```
239243

240244
## Spatial Analysis

0 commit comments

Comments
 (0)