Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
pyMOR
pymor
Commits
c20bf6f2
Commit
c20bf6f2
authored
Jul 17, 2020
by
Hendrik Kleikamp
Committed by
René Fritze
Jul 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[gui] enable separate axes for subplots
parent
f6fdfc91
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
11 deletions
+44
-11
notebooks/elliptic_oned.ipynb
notebooks/elliptic_oned.ipynb
+1
-1
src/pymor/discretizers/builtin/gui/jupyter/matplotlib.py
src/pymor/discretizers/builtin/gui/jupyter/matplotlib.py
+37
-5
src/pymor/discretizers/builtin/gui/matplotlib.py
src/pymor/discretizers/builtin/gui/matplotlib.py
+4
-3
src/pymor/discretizers/builtin/gui/visualizers.py
src/pymor/discretizers/builtin/gui/visualizers.py
+2
-2
No files found.
notebooks/elliptic_oned.ipynb
View file @
c20bf6f2
...
...
@@ -71,7 +71,7 @@
"U = m.solution_space.empty()\n",
"for mu in parameter_space.sample_uniformly(10):\n",
" U.append(m.solve(mu))\n",
"m.visualize(U, title='Solution for diffusionl in [0.1, 1]', separate_plots=False)"
"m.visualize(U, title='Solution for diffusionl in [0.1, 1]', separate_plots=
True, separate_axes=
False)"
]
}
],
...
...
src/pymor/discretizers/builtin/gui/jupyter/matplotlib.py
View file @
c20bf6f2
...
...
@@ -125,7 +125,35 @@ def visualize_patch(grid, U, bounding_box=([0, 0], [1, 1]), codim=2, title=None,
return
None
def
visualize_matplotlib_1d
(
grid
,
U
,
codim
=
1
,
title
=
None
,
legend
=
None
,
separate_plots
=
False
,
columns
=
2
):
def
visualize_matplotlib_1d
(
grid
,
U
,
codim
=
1
,
title
=
None
,
legend
=
None
,
separate_plots
=
False
,
separate_axes
=
False
,
columns
=
2
):
"""Visualize scalar data associated to a one-dimensional |Grid| as a plot.
The grid's |ReferenceElement| must be the line. The data can either
be attached to the subintervals or vertices of the grid.
Parameters
----------
grid
The underlying |Grid|.
U
|VectorArray| of the data to visualize. If `len(U) > 1`, the data is visualized
as a time series of plots. Alternatively, a tuple of |VectorArrays| can be
provided, in which case several plots are made into the same axes. The
lengths of all arrays have to agree.
codim
The codimension of the entities the data in `U` is attached to (either 0 or 1).
title
Title of the plot.
legend
Description of the data that is plotted. Most useful if `U` is a tuple in which
case `legend` has to be a tuple of strings of the same length.
separate_plots
If `True`, use subplots to visualize multiple |VectorArrays|.
separate_axes
If `True`, use separate axes for each subplot.
column
Number of columns the subplots are organized in.
"""
assert
isinstance
(
U
,
VectorArray
)
\
or
(
isinstance
(
U
,
tuple
)
and
all
(
isinstance
(
u
,
VectorArray
)
for
u
in
U
)
...
...
@@ -146,11 +174,15 @@ def visualize_matplotlib_1d(grid, U, codim=1, title=None, legend=None, separate_
def
__init__
(
self
):
if
separate_plots
:
self
.
vmins
=
tuple
(
np
.
min
(
u
)
for
u
in
U
[
0
])
self
.
vmaxs
=
tuple
(
np
.
max
(
u
)
for
u
in
U
[
0
])
if
separate_axes
:
self
.
vmins
=
tuple
(
np
.
min
(
u
)
for
u
in
U
[
0
])
self
.
vmaxs
=
tuple
(
np
.
max
(
u
)
for
u
in
U
[
0
])
else
:
self
.
vmins
=
(
min
(
np
.
min
(
u
)
for
u
in
U
),)
*
len
(
U
[
0
])
self
.
vmaxs
=
(
max
(
np
.
max
(
u
)
for
u
in
U
),)
*
len
(
U
[
0
])
else
:
self
.
vmins
=
(
min
(
np
.
min
(
u
)
for
u
in
U
),)
self
.
vmaxs
=
(
max
(
np
.
max
(
u
)
for
u
in
U
),)
self
.
vmins
=
(
min
(
np
.
min
(
u
)
for
u
in
U
[
0
]
),)
self
.
vmaxs
=
(
max
(
np
.
max
(
u
)
for
u
in
U
[
0
]
),)
import
matplotlib.pyplot
as
plt
...
...
src/pymor/discretizers/builtin/gui/matplotlib.py
View file @
c20bf6f2
...
...
@@ -2,9 +2,9 @@
# Copyright 2013-2020 pyMOR developers and contributors. All rights reserved.
# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
""" This module provides
a
widgets for displaying plots of
""" This module provides widgets for displaying plots of
scalar data assigned to one- and two-dimensional grids using
:mod:`matplotlib`. Th
is
widget
is
not intended to be used directly.
:mod:`matplotlib`. Th
ese
widget
s are
not intended to be used directly.
"""
import
numpy
as
np
...
...
@@ -101,7 +101,8 @@ class Matplotlib1DAxes:
else
:
self
.
lines
[
i
].
set_ydata
(
np
.
repeat
(
u
,
2
))
self
.
axes
.
set_ylim
(
self
.
vmin
,
self
.
vmax
)
pad
=
(
self
.
vmax
-
self
.
vmin
)
*
0.1
self
.
axes
.
set_ylim
(
self
.
vmin
-
pad
,
self
.
vmax
+
pad
)
if
config
.
HAVE_QT
and
config
.
HAVE_MATPLOTLIB
:
...
...
src/pymor/discretizers/builtin/gui/visualizers.py
View file @
c20bf6f2
...
...
@@ -118,7 +118,7 @@ class OnedVisualizer(BasicObject):
self
.
__auto_init
(
locals
())
def
visualize
(
self
,
U
,
m
,
title
=
None
,
legend
=
None
,
separate_plots
=
False
,
block
=
None
,
filename
=
None
,
columns
=
2
):
separate_axes
=
False
,
block
=
None
,
filename
=
None
,
columns
=
2
):
"""Visualize the provided data.
Parameters
...
...
@@ -145,7 +145,7 @@ class OnedVisualizer(BasicObject):
if
self
.
backend
==
'jupyter'
:
from
pymor.discretizers.builtin.gui.jupyter.matplotlib
import
visualize_matplotlib_1d
return
visualize_matplotlib_1d
(
self
.
grid
,
U
,
codim
=
self
.
codim
,
title
=
title
,
legend
=
legend
,
separate_plots
=
separate_plots
,
columns
=
columns
)
separate_plots
=
separate_plots
,
separate_axes
=
separate_axes
,
columns
=
columns
)
else
:
block
=
self
.
block
if
block
is
None
else
block
from
pymor.discretizers.builtin.gui.qt
import
visualize_matplotlib_1d
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment