Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OGSTools
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
Service Desk
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ogs
OpenGeoSys Tools
OGSTools
Commits
6fc92a3c
Commit
6fc92a3c
authored
1 year ago
by
Florian Zill
Browse files
Options
Downloads
Patches
Plain Diff
[meshplotlib] colormap fix, label format fix
parent
d8175a52
No related branches found
No related tags found
1 merge request
!119
Stress Analysis and Refactoring
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ogstools/meshplotlib/core.py
+18
-8
18 additions, 8 deletions
ogstools/meshplotlib/core.py
with
18 additions
and
8 deletions
ogstools/meshplotlib/core.py
+
18
−
8
View file @
6fc92a3c
...
...
@@ -52,20 +52,26 @@ def get_cmap_norm(
vmin
+=
0.5
vmax
+=
0.5
if
isinstance
(
property
.
cmap
,
str
):
continuous_cmap
=
colormaps
[
property
.
cmap
]
else
:
continuous_cmap
=
property
.
cmap
if
property
.
bilinear_cmap
:
if
vmin
<=
0.0
<=
vmax
:
vcenter
=
0.0
vmin
,
vmax
=
np
.
max
(
np
.
abs
([
vmin
,
vmax
]))
*
np
.
array
([
-
1.0
,
1.0
])
conti_norm
=
mcolors
.
TwoSlopeNorm
(
vcenter
,
vmin
,
vmax
)
else
:
# only use one half of the diverging colormap
vcenter
=
nextafter
(
*
sorted
([
vmin
,
vmax
],
reverse
=
(
vmin
<=
0.0
)))
conti_norm
=
mcolors
.
TwoSlopeNorm
(
vcenter
,
vmin
,
vmax
)
col_range
=
np
.
linspace
(
0.0
,
nextafter
(
0.5
,
-
np
.
inf
),
128
)
if
vmax
>
0.0
:
col_range
+=
0.5
continuous_cmap
=
mcolors
.
LinearSegmentedColormap
.
from_list
(
"
half_cmap
"
,
continuous_cmap
(
col_range
)
)
conti_norm
=
mcolors
.
Normalize
(
vmin
,
vmax
)
else
:
conti_norm
=
mcolors
.
Normalize
(
vmin
,
vmax
)
if
isinstance
(
property
.
cmap
,
str
):
continuous_cmap
=
colormaps
[
property
.
cmap
]
else
:
continuous_cmap
=
property
.
cmap
mid_levels
=
np
.
append
((
levels
[:
-
1
]
+
levels
[
1
:])
*
0.5
,
levels
[
-
1
])
colors
=
[
continuous_cmap
(
conti_norm
(
m_l
))
for
m_l
in
mid_levels
]
cmap
=
mcolors
.
ListedColormap
(
colors
,
name
=
"
custom
"
)
...
...
@@ -119,10 +125,14 @@ def add_colorbars(
# formatting the colorbar ticks
cb
.
ax
.
tick_params
(
labelsize
=
labelsize
,
direction
=
"
out
"
)
cb
.
ax
.
yaxis
.
set_major_formatter
(
mticker
.
FormatStrFormatter
(
"
%.3g
"
))
# "+ 0" prevents output of negative zero, i.e. "-0"
tick_labels
=
[
f
"
{
round
(
tick
,
POWER_LIMIT
)
:
.
{
POWER_LIMIT
}
g
}
"
for
tick
in
ticks
f
"
{
round
(
tick
,
POWER_LIMIT
)
+
0
:
.
{
POWER_LIMIT
}
g
}
"
for
tick
in
ticks
]
if
tick_labels
[
0
]
==
tick_labels
[
1
]:
tick_labels
[
0
]
=
f
"
{
ticks
[
0
]
:
.
2
e
}
"
if
tick_labels
[
-
2
]
==
tick_labels
[
-
1
]:
tick_labels
[
-
1
]
=
f
"
{
ticks
[
-
1
]
:
.
1
e
}
"
if
property
.
data_name
==
"
MaterialIDs
"
and
setup
.
material_names
is
not
None
:
tick_labels
=
[
setup
.
material_names
.
get
(
mat_id
,
mat_id
)
for
mat_id
in
levels
...
...
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