Update src/seismic_hazard_forecasting.py
stretch image to exact borders of svg file
This commit is contained in:
@@ -870,21 +870,20 @@ verbose: {verbose}")
|
|||||||
east, west = grid_lon_max, grid_lon_min # Longitude range
|
east, west = grid_lon_max, grid_lon_min # Longitude range
|
||||||
bounds = [[south, west], [north, east]]
|
bounds = [[south, west], [north, east]]
|
||||||
|
|
||||||
logger.debug(f"Grid extent North {north}, South {south}, East {east}, West {west}")
|
|
||||||
|
|
||||||
map_center = [np.mean([north, south]), np.mean([east, west])]
|
map_center = [np.mean([north, south]), np.mean([east, west])]
|
||||||
|
|
||||||
# Create an image from the grid
|
# Create an image from the grid
|
||||||
cmap_name = 'YlOrRd'
|
cmap_name = 'YlOrRd'
|
||||||
cmap = plt.get_cmap(cmap_name)
|
cmap = plt.get_cmap(cmap_name)
|
||||||
fig, ax = plt.subplots(figsize=(6, 6))
|
fig, ax = plt.subplots(figsize=(6, 6))
|
||||||
ax.imshow(iml_grid_hd, origin='lower', cmap=cmap, vmin=vmin, vmax=vmax, interpolation='bilinear')
|
fig.add_axes([0, 0, 1, 1])
|
||||||
|
ax.imshow(iml_grid_hd, origin='lower', cmap=cmap, vmin=vmin, vmax=vmax, interpolation='bilinear', aspect='auto')
|
||||||
ax.axis('off')
|
ax.axis('off')
|
||||||
|
|
||||||
# Save the figure
|
# Save the figure
|
||||||
fig.canvas.draw()
|
fig.canvas.draw()
|
||||||
overlay_filename = f"overlay_{j}.svg"
|
overlay_filename = f"overlay_{j}.svg"
|
||||||
plt.savefig(overlay_filename, bbox_inches="tight", pad_inches=0, transparent=True)
|
plt.savefig(overlay_filename, pad_inches=0, transparent=True)
|
||||||
plt.close(fig)
|
plt.close(fig)
|
||||||
|
|
||||||
# Embed geographic bounding box into the SVG
|
# Embed geographic bounding box into the SVG
|
||||||
|
|||||||
Reference in New Issue
Block a user