Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
empyre
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dieter Weber
empyre
Commits
e85a58da
Commit
e85a58da
authored
3 years ago
by
Jan Caron
Browse files
Options
Downloads
Plain Diff
Merge branch 'matplotlib-fix' into 'master'
Fixed deprecated DivergingNorm -> TwoSlopeNorm See merge request
!39
parents
7f40b76f
88377a32
Branches
master
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#51665
failed
2 years ago
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
environment.yml
+1
-1
1 addition, 1 deletion
environment.yml
setup.cfg
+1
-1
1 addition, 1 deletion
setup.cfg
src/empyre/vis/plot2d.py
+8
-5
8 additions, 5 deletions
src/empyre/vis/plot2d.py
with
10 additions
and
7 deletions
environment.yml
+
1
−
1
View file @
e85a58da
...
...
@@ -24,7 +24,7 @@ dependencies:
-
hyperspy-gui-ipywidgets=1.2
#- h5py=2.9 # TODO: dependency of hyperspy? Not needed here?
# Plotting and colors:
-
matplotlib=3.
1
-
matplotlib=3.
2
-
Pillow=6.1
-
cmocean=2.0
# 3D plotting:
...
...
This diff is collapsed.
Click to expand it.
setup.cfg
+
1
−
1
View file @
e85a58da
...
...
@@ -40,7 +40,7 @@ setup_requires =
setuptools
install_requires
=
numpy
>=
1.17
matplotlib
>=
3
matplotlib
>=
3
.2
scikit-image
tqdm
scipy
...
...
This diff is collapsed.
Click to expand it.
src/empyre/vis/plot2d.py
+
8
−
5
View file @
e85a58da
...
...
@@ -10,7 +10,7 @@ import warnings
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
matplotlib.colors
import
Diverging
Norm
from
matplotlib.colors
import
TwoSlope
Norm
from
PIL
import
Image
from
.
import
colors
...
...
@@ -76,9 +76,10 @@ def imshow(field, axis=None, cmap=None, **kwargs):
elif
isinstance
(
cmap
,
str
):
# make sure we have a Colormap object (and not a string):
cmap
=
plt
.
get_cmap
(
cmap
)
if
cmap
.
name
.
replace
(
'
_r
'
,
''
)
in
DIVERGING_CMAPS
:
# 'replace' also matches reverted cmaps!
kwargs
.
setdefault
(
'
norm
'
,
Diverging
Norm
(
0
))
# Diverging colormap should have zero at the symmetry point!
kwargs
.
setdefault
(
'
norm
'
,
TwoSlope
Norm
(
0
))
# Diverging colormap should have zero at the symmetry point!
# Set extent in data coordinates (left, right, bottom, top) to kwargs (if not set explicitely):
dim_v
,
dim_u
,
s_v
,
s_u
=
*
squeezed_field
.
dim
,
*
squeezed_field
.
scale
dim_v
,
dim_u
=
squeezed_field
.
dim
s_v
,
s_u
=
squeezed_field
.
scale
kwargs
.
setdefault
(
'
extent
'
,
(
0
,
dim_u
*
s_u
,
0
,
dim_v
*
s_v
))
# Plot with the empyre style context:
with
use_style
(
'
empyre-image
'
):
# Only works on axes created WITHIN context!
...
...
@@ -191,7 +192,8 @@ def colorvec(field, axis=None, **kwargs):
cmap
=
colors
.
cmaps
.
cyclic_cubehelix
rgb
=
cmap
.
rgb_from_vector
(
np
.
stack
((
x_comp
,
y_comp
,
z_comp
),
axis
=
0
))
# Set extent in data coordinates (left, right, bottom, top) to kwargs (if not set explicitely):
dim_v
,
dim_u
,
s_v
,
s_u
=
*
squeezed_field
.
dim
,
*
squeezed_field
.
scale
dim_v
,
dim_u
=
squeezed_field
.
dim
s_v
,
s_u
=
squeezed_field
.
scale
kwargs
.
setdefault
(
'
extent
'
,
(
0
,
dim_u
*
s_u
,
0
,
dim_v
*
s_v
))
# Plot with the empyre style context:
with
use_style
(
'
empyre-image
'
):
# Only works on axes created WITHIN context!
...
...
@@ -249,7 +251,8 @@ def cosine_contours(field, axis=None, gain='auto', cmap=None, **kwargs):
contours
+=
1
# Shift to positive values
contours
/=
2
# Rescale to [0, 1]
# Set extent in data coordinates (left, right, bottom, top) to kwargs (if not set explicitely):
dim_v
,
dim_u
,
s_v
,
s_u
=
*
squeezed_field
.
dim
,
*
squeezed_field
.
scale
dim_v
,
dim_u
=
squeezed_field
.
dim
s_v
,
s_u
=
squeezed_field
.
scale
kwargs
.
setdefault
(
'
extent
'
,
(
0
,
dim_u
*
s_u
,
0
,
dim_v
*
s_v
))
# Plot with the empyre style context:
with
use_style
(
'
empyre-image
'
):
# Only works on axes created WITHIN context!
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment