from pathlib import Path


def filename_for_plot(directory, zarr_path: str, qualifier: str = "") -> str:
    """Get a suitable output filename for a plot produced from a Zarr path"""
    basename = Path(zarr_path).stem.replace(
        ".zarr", ""
    )  # handle ".zarr" and ".zarr.zip"
    path = Path(directory, f"{basename}{qualifier}.png")
    return str(path)