Skip to content
Snippets Groups Projects
Commit 09ea2352 authored by Alessia Saccardo's avatar Alessia Saccardo
Browse files

fix histogram layout and add legend

parent f99719f6
No related branches found
No related tags found
1 merge request!135Threshold exploration
This commit is part of merge request !135. Comments created here will be created in the context of that merge request.
......@@ -819,6 +819,7 @@ def histogram(
vol: np.ndarray,
bins: Union[int, str] = "auto",
slice_idx: Union[int, str, None] = None,
threshold: int = None,
axis: int = 0,
kde: bool = True,
log_scale: bool = False,
......@@ -909,8 +910,28 @@ def histogram(
**sns_kwargs,
)
if threshold is not None:
ax.axvline(
x=threshold,
color='red',
linestyle="--",
linewidth=2,
label=f"Threshold = {round(threshold)}"
)
ax.legend()
if despine:
sns.despine(ax=ax, top=True, right=True)
sns.despine(
fig=None,
ax=ax,
top=True,
right=True,
left=False,
bottom=False,
offset={"left": 0, "bottom": 18},
trim=True,
)
ax.set_xlabel("Voxel Intensity")
ax.set_ylabel("Frequency")
......@@ -1036,19 +1057,14 @@ def threshold(
vol=volume,
bins=32,
slice_idx=position,
threshold=threshold,
axis=1,
kde=False,
ax=axes[1],
show=False,
)
axes[1].axvline(
x=threshold,
color="red",
linestyle="--",
linewidth=2,
label=f"Threshold = {threshold}",
)
axes[1].set_title("Histogram")
axes[1].set_title(f'Histogram')
# Compute and add the binary mask to the plot
mask = slice_img > threshold
......@@ -1056,6 +1072,8 @@ def threshold(
axes[2].set_title('Binary mask')
axes[2].axis('off')
# both mask and img should be rgb
# mask data in first channel and then black the other sure --> no cmap_overlay
# Compute and add the overlay to the plot
masked_volume = qim3d.processing.operations.overlay_rgb_images(
background = slice_img,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment