Skip to content
Snippets Groups Projects

Viz add colorbar

1 file
+ 9
0
Compare changes
  • Side-by-side
  • Inline
+ 9
0
@@ -8,6 +8,7 @@ from typing import List, Optional, Union
import dask.array as da
import ipywidgets as widgets
import matplotlib.pyplot as plt
import matplotlib
import numpy as np
import qim3d
@@ -28,6 +29,7 @@ def slices(
show_position: bool = True,
interpolation: Optional[str] = "none",
img_size=None,
cbar: bool = False,
**imshow_kwargs,
) -> plt.Figure:
"""Displays one or several slices from a 3d volume.
@@ -181,6 +183,11 @@ def slices(
# Hide the axis, so that we have a nice grid
ax.axis("off")
if cbar:
norm = matplotlib.colors.Normalize(vmin=vmin, vmax=vmax, clip=True)
mappable = matplotlib.cm.ScalarMappable(norm=norm, cmap=cmap)
fig.colorbar(mappable=mappable, ax=axs, orientation='vertical')
if show:
plt.show()
@@ -216,6 +223,7 @@ def slicer(
show_position: bool = False,
interpolation: Optional[str] = "none",
img_size=None,
cbar: bool = False,
**imshow_kwargs,
) -> widgets.interactive:
"""Interactive widget for visualizing slices of a 3D volume.
@@ -263,6 +271,7 @@ def slicer(
position=position,
n_slices=1,
show=True,
cbar=cbar,
**imshow_kwargs,
)
return fig
Loading