Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qim3d
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tools
qim3d
Merge requests
!124
Viz add colorbar
Code
Review changes
Check out branch
Open in Workspace
Download
Patches
Plain diff
Expand sidebar
Merged
Viz add colorbar
viz-add-colorbar
into
main
Overview
0
Commits
6
Pipelines
0
Changes
1
Merged
s214743
requested to merge
viz-add-colorbar
into
main
8 months ago
Overview
0
Commits
6
Pipelines
0
Changes
1
https://www.notion.so/qim-dtu/Add-colorbar-to-vizualisation-tools-a1b4cb67bd4a4de39a7ac40bf5d35fd5
0
0
Merge request reports
Viewing commit
2a8b7ed0
Prev
Next
Show latest version
1 file
+
12
−
5
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
2a8b7ed0
changed vrange behaviour for cbar=True
· 2a8b7ed0
David Johansen
authored
8 months ago
qim3d/viz/explore.py
+
12
−
5
View file @ 2a8b7ed0
Edit in single-file editor
Open in Web IDE
Show full file
@@ -137,6 +137,11 @@ def slices(
if
isinstance
(
vol
,
da
.
core
.
Array
):
vol
=
vol
.
compute
()
if
cbar
:
# In this case, we want the vrange to be constant across the slices, which makes them all comparable to a single cbar.
new_vmin
=
vmin
if
vmin
else
np
.
min
(
vol
)
new_vmax
=
vmax
if
vmax
else
np
.
max
(
vol
)
# Run through each ax of the grid
for
i
,
ax_row
in
enumerate
(
axs
):
for
j
,
ax
in
enumerate
(
np
.
atleast_1d
(
ax_row
)):
@@ -144,10 +149,12 @@ def slices(
try
:
slice_img
=
vol
.
take
(
slice_idxs
[
slice_idx
],
axis
=
axis
)
# If vmin is higher than the highest value in the image ValueError is raised
# We don't want to override the values because next slices might be okay
new_vmin
=
None
if
(
isinstance
(
vmin
,
(
float
,
int
))
and
vmin
>
np
.
max
(
slice_img
))
else
vmin
new_vmax
=
None
if
(
isinstance
(
vmax
,
(
float
,
int
))
and
vmax
<
np
.
min
(
slice_img
))
else
vmax
if
not
cbar
:
# If vmin is higher than the highest value in the image ValueError is raised
# We don't want to override the values because next slices might be okay
new_vmin
=
None
if
(
isinstance
(
vmin
,
(
float
,
int
))
and
vmin
>
np
.
max
(
slice_img
))
else
vmin
new_vmax
=
None
if
(
isinstance
(
vmax
,
(
float
,
int
))
and
vmax
<
np
.
min
(
slice_img
))
else
vmax
ax
.
imshow
(
slice_img
,
cmap
=
cmap
,
interpolation
=
interpolation
,
vmin
=
new_vmin
,
vmax
=
new_vmax
,
**
imshow_kwargs
)
@@ -185,7 +192,7 @@ def slices(
ax
.
axis
(
"
off
"
)
if
cbar
:
norm
=
matplotlib
.
colors
.
Normalize
(
vmin
=
vmin
,
vmax
=
vmax
,
clip
=
True
)
norm
=
matplotlib
.
colors
.
Normalize
(
vmin
=
new_
vmin
,
vmax
=
new_
vmax
,
clip
=
True
)
mappable
=
matplotlib
.
cm
.
ScalarMappable
(
norm
=
norm
,
cmap
=
cmap
)
fig
.
colorbar
(
mappable
=
mappable
,
ax
=
np
.
atleast_1d
(
axs
[
0
])[
-
1
],
orientation
=
'
vertical
'
)
Loading