grayscale spill map
This commit is contained in:
@@ -438,6 +438,9 @@ def map_hex(spills: gpd.GeoDataFrame, boundary: gpd.GeoDataFrame, counties: gpd.
|
||||
|
||||
# Use hexbin; gridsize tuned to CO scale; mincnt to suppress isolated cells
|
||||
hb = ax.hexbin(x, y, gridsize=70, mincnt=3, cmap='viridis', alpha=0.9, zorder=3)
|
||||
# Outline hexagons so low-density bins remain legible
|
||||
hb.set_edgecolors((0, 0, 0, 0.25))
|
||||
hb.set_linewidth(0.15)
|
||||
cb = fig.colorbar(hb, ax=ax, fraction=0.028, pad=0.01)
|
||||
cb.set_label('Spill count')
|
||||
|
||||
@@ -469,6 +472,41 @@ def map_hex(spills: gpd.GeoDataFrame, boundary: gpd.GeoDataFrame, counties: gpd.
|
||||
fig.savefig(out_pdf)
|
||||
fig.savefig(out_png, dpi=600, bbox_inches='tight', pad_inches=0.1)
|
||||
plt.close(fig)
|
||||
|
||||
# Grayscale PNG version for print-friendly workflows
|
||||
fig_g, ax_g = plt.subplots(figsize=(7, 9), dpi=300, constrained_layout=True)
|
||||
boundary_3857.plot(ax=ax_g, color='#f5f5f5', edgecolor='#888888', linewidth=0.8)
|
||||
if counties is not None and not counties.empty:
|
||||
counties_3857 = counties.to_crs(3857)
|
||||
counties_3857.boundary.plot(ax=ax_g, color='#777777', linewidth=0.35)
|
||||
|
||||
hb_g = ax_g.hexbin(x, y, gridsize=70, mincnt=3, cmap='Greys', alpha=0.95, zorder=3)
|
||||
# Outline hexagons so low-density bins remain legible
|
||||
hb_g.set_edgecolors((0, 0, 0, 0.25))
|
||||
hb_g.set_linewidth(0.15)
|
||||
cb_g = fig_g.colorbar(hb_g, ax=ax_g, fraction=0.028, pad=0.01)
|
||||
cb_g.set_label('Spill count')
|
||||
|
||||
# Draw county boundaries on top for visibility
|
||||
if counties is not None and not counties.empty:
|
||||
counties_3857.boundary.plot(ax=ax_g, color='#222222', linewidth=0.6, zorder=4)
|
||||
|
||||
# Cities + county labels + bold target borders
|
||||
cities_g = get_cities_gdf().to_crs(3857)
|
||||
plot_cities(ax_g, cities_g)
|
||||
label_selected_counties(ax_g, counties)
|
||||
bold_target_county_borders(ax_g, counties)
|
||||
|
||||
ax_g.add_artist(ScaleBar(1, units='m', location='lower left', box_alpha=0.7))
|
||||
add_north_arrow(ax_g)
|
||||
ax_g.set_xlim(minx, maxx)
|
||||
ax_g.set_ylim(miny, maxy)
|
||||
style_axes(ax_g)
|
||||
|
||||
out_gray_png = OUT / 'spill_map_hex_gray.png'
|
||||
fig_g.savefig(out_gray_png, dpi=600, bbox_inches='tight', pad_inches=0.1)
|
||||
plt.close(fig_g)
|
||||
|
||||
return out_pdf
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user