Skip to content

Commit

Permalink
change debug behavior to be MPL compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
HaleySchuhl committed Dec 5, 2024
1 parent 2df4be0 commit ef94716
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions plantcv/geospatial/analyze/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,28 @@ def coverage(img, bin_mask, geojson):

# Plot the GeoTIFF
_, ax = plt.subplots(figsize=(10, 10))
fig_extent = plotting_extent(img.array_data[:, :, :3], img.metadata['transform'])
fig_extent = plotting_extent(img.array_data[:, :, :3],
img.metadata['transform'])
ax.imshow(img.pseudo_rgb, extent=fig_extent)
# Plot the shapefile
shapefile.boundary.plot(ax=ax, color="red")
bounds.boundary.plot(ax=ax, color="red")
# Set plot title and labels
plt.title("Shapefile on GeoTIFF")
plt.xlabel("Longitude")
plt.ylabel("Latitude")
# Store the plot
plotting_img = plt.gcf()

_debug(visual=plotting_img,
filename=os.path.join(params.debug_outdir, f"{params.device}_analyze_coverage.png"))
# Print or plot if debug is turned on
if params.debug is not None:
if params.debug == 'print':
plt.savefig(os.path.join(params.debug_outdir, str(
params.device) + '_analyze_coverage.png'), dpi=params.dpi)
plt.close()
elif params.debug == 'plot':
# Use non-blocking mode in case the function is run more than once
plt.show(block=False)
else:
plt.close()

return plotting_img

0 comments on commit ef94716

Please sign in to comment.