Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
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
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
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
mlz
BornAgain
Commits
a97cc038
Commit
a97cc038
authored
4 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
plot_utils: title now as kwargs
parent
9bfd4263
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Wrap/Python/plot_utils.py
+10
-7
10 additions, 7 deletions
Wrap/Python/plot_utils.py
with
10 additions
and
7 deletions
Wrap/Python/plot_utils.py
+
10
−
7
View file @
a97cc038
...
@@ -84,7 +84,7 @@ def get_axes_labels(result, units):
...
@@ -84,7 +84,7 @@ def get_axes_labels(result, units):
return
labels
return
labels
def
plot_array
(
array
,
title
=
None
,
axes_limits
=
None
,
**
kwargs
):
def
plot_array
(
array
,
axes_limits
=
None
,
**
kwargs
):
"""
"""
Plots numpy array as a colormap in log scale.
Plots numpy array as a colormap in log scale.
"""
"""
...
@@ -101,6 +101,8 @@ def plot_array(array, title=None, axes_limits=None, **kwargs):
...
@@ -101,6 +101,8 @@ def plot_array(array, title=None, axes_limits=None, **kwargs):
ylabel
=
kwargs
.
pop
(
'
ylabel
'
,
None
)
ylabel
=
kwargs
.
pop
(
'
ylabel
'
,
None
)
zlabel
=
kwargs
.
pop
(
'
zlabel
'
,
"
Intensity
"
)
zlabel
=
kwargs
.
pop
(
'
zlabel
'
,
"
Intensity
"
)
title
=
kwargs
.
pop
(
'
title
'
,
None
)
im
=
plt
.
imshow
(
array
,
norm
=
norm
,
extent
=
axes_limits
,
**
kwargs
)
im
=
plt
.
imshow
(
array
,
norm
=
norm
,
extent
=
axes_limits
,
**
kwargs
)
cb
=
plt
.
colorbar
(
im
,
pad
=
0.025
)
cb
=
plt
.
colorbar
(
im
,
pad
=
0.025
)
...
@@ -115,7 +117,7 @@ def plot_array(array, title=None, axes_limits=None, **kwargs):
...
@@ -115,7 +117,7 @@ def plot_array(array, title=None, axes_limits=None, **kwargs):
plt
.
title
(
title
)
plt
.
title
(
title
)
def
plot_histogram
(
hist
,
title
=
None
,
**
kwargs
):
def
plot_histogram
(
hist
,
**
kwargs
):
"""
"""
Plots intensity data as color map
Plots intensity data as color map
:param intensity: Histogram2D object obtained from GISASSimulation
:param intensity: Histogram2D object obtained from GISASSimulation
...
@@ -135,10 +137,12 @@ def plot_histogram(hist, title=None, **kwargs):
...
@@ -135,10 +137,12 @@ def plot_histogram(hist, title=None, **kwargs):
hist
.
getYmax
()
hist
.
getYmax
()
]
]
title
=
kwargs
.
pop
(
'
title
'
,
None
)
plot_array
(
hist
.
array
(),
title
=
title
,
axes_limits
=
axes_limits
,
**
kwargs
)
plot_array
(
hist
.
array
(),
title
=
title
,
axes_limits
=
axes_limits
,
**
kwargs
)
def
plot_colormap
(
result
,
units
=
ba
.
Axes
.
DEFAULT
,
title
=
None
,
**
kwargs
):
def
plot_colormap
(
result
,
units
=
ba
.
Axes
.
DEFAULT
,
**
kwargs
):
"""
"""
Plots intensity data as color map
Plots intensity data as color map
:param result: SimulationResult from GISAS/OffSpecSimulation
:param result: SimulationResult from GISAS/OffSpecSimulation
...
@@ -154,14 +158,13 @@ def plot_colormap(result, units=ba.Axes.DEFAULT, title=None, **kwargs):
...
@@ -154,14 +158,13 @@ def plot_colormap(result, units=ba.Axes.DEFAULT, title=None, **kwargs):
if
not
'
ylabel
'
in
kwargs
:
if
not
'
ylabel
'
in
kwargs
:
kwargs
[
'
ylabel
'
]
=
axes_labels
[
1
]
kwargs
[
'
ylabel
'
]
=
axes_labels
[
1
]
plot_array
(
result
.
array
(),
title
=
title
,
axes_limits
=
axes_limits
,
**
kwargs
)
plot_array
(
result
.
array
(),
axes_limits
=
axes_limits
,
**
kwargs
)
def
plot_specular_simulation_result
(
result
,
def
plot_specular_simulation_result
(
result
,
ymin
=
None
,
ymin
=
None
,
ymax
=
None
,
ymax
=
None
,
units
=
ba
.
Axes
.
DEFAULT
,
units
=
ba
.
Axes
.
DEFAULT
,
title
=
None
,
**
kwargs
):
**
kwargs
):
"""
"""
Plots intensity data for specular simulation result
Plots intensity data for specular simulation result
...
@@ -179,6 +182,7 @@ def plot_specular_simulation_result(result,
...
@@ -179,6 +182,7 @@ def plot_specular_simulation_result(result,
xlabel
=
kwargs
.
pop
(
'
xlabel
'
,
get_axes_labels
(
result
,
units
)[
0
])
xlabel
=
kwargs
.
pop
(
'
xlabel
'
,
get_axes_labels
(
result
,
units
)[
0
])
ylabel
=
kwargs
.
pop
(
'
ylabel
'
,
"
Intensity
"
)
ylabel
=
kwargs
.
pop
(
'
ylabel
'
,
"
Intensity
"
)
title
=
kwargs
.
pop
(
'
title
'
,
None
)
plt
.
semilogy
(
x_axis
,
intensity
,
**
kwargs
)
plt
.
semilogy
(
x_axis
,
intensity
,
**
kwargs
)
...
@@ -196,7 +200,6 @@ def plot_specular_simulation_result(result,
...
@@ -196,7 +200,6 @@ def plot_specular_simulation_result(result,
def
plot_simulation_result
(
result
,
def
plot_simulation_result
(
result
,
units
=
ba
.
Axes
.
DEFAULT
,
units
=
ba
.
Axes
.
DEFAULT
,
postpone_show
=
False
,
postpone_show
=
False
,
title
=
None
,
**
kwargs
):
**
kwargs
):
"""
"""
Draws simulation result and (optionally) shows the plot.
Draws simulation result and (optionally) shows the plot.
...
@@ -209,7 +212,7 @@ def plot_simulation_result(result,
...
@@ -209,7 +212,7 @@ def plot_simulation_result(result,
if
len
(
result
.
array
().
shape
)
==
1
:
# 1D data, specular simulation assumed
if
len
(
result
.
array
().
shape
)
==
1
:
# 1D data, specular simulation assumed
plot_specular_simulation_result
(
result
,
units
,
**
kwargs
)
plot_specular_simulation_result
(
result
,
units
,
**
kwargs
)
else
:
else
:
plot_colormap
(
result
,
units
,
title
=
title
,
**
kwargs
)
plot_colormap
(
result
,
units
,
**
kwargs
)
plt
.
tight_layout
()
plt
.
tight_layout
()
if
not
(
postpone_show
):
if
not
(
postpone_show
):
plt
.
show
()
plt
.
show
()
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