Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
P
pymor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Insights
Issue
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
pyMOR
pymor
Commits
fb65067d
Commit
fb65067d
authored
Jul 16, 2020
by
René Fritze
Committed by
René Fritze
Jul 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[vis] cleanup MPL animation code a little
parent
05c36229
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
21 deletions
+11
-21
src/pymor/discretizers/builtin/gui/jupyter/matplotlib.py
src/pymor/discretizers/builtin/gui/jupyter/matplotlib.py
+4
-9
src/pymor/discretizers/builtin/gui/matplotlib.py
src/pymor/discretizers/builtin/gui/matplotlib.py
+7
-12
No files found.
src/pymor/discretizers/builtin/gui/jupyter/matplotlib.py
View file @
fb65067d
...
...
@@ -3,7 +3,7 @@
# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
import
numpy
as
np
from
ipywidgets
import
HTML
,
HBox
from
matplotlib
import
pyplo
t
import
matplotlib.pyplot
as
pl
t
from
pymor.core.config
import
config
from
pymor.discretizers.builtin.gui.matplotlib
import
MatplotlibPatchAxes
,
Matplotlib1DAxes
...
...
@@ -81,27 +81,20 @@ def visualize_patch(grid, U, bounding_box=([0, 0], [1, 1]), codim=2, title=None,
self
.
vmins
=
(
min
(
np
.
min
(
u
)
for
u
in
U
),)
*
len
(
U
)
self
.
vmaxs
=
(
max
(
np
.
max
(
u
)
for
u
in
U
),)
*
len
(
U
)
import
matplotlib.pyplot
as
plt
rows
=
int
(
np
.
ceil
(
len
(
U
)
/
columns
))
self
.
figure
=
figure
=
plt
.
figure
()
self
.
plots
=
plots
=
[]
axes
=
[]
for
i
,
(
vmin
,
vmax
,
u
)
in
enumerate
(
zip
(
self
.
vmins
,
self
.
vmaxs
,
U
)):
# we do not use figures.subplots since conditionally returns an axes array or a single object
ax
=
figure
.
add_subplot
(
rows
,
columns
,
i
+
1
)
axes
.
append
(
ax
)
plots
.
append
(
MatplotlibPatchAxes
(
U
=
u
,
ax
=
ax
,
figure
=
figure
,
grid
=
grid
,
bounding_box
=
bounding_box
,
vmin
=
vmin
,
vmax
=
vmax
,
codim
=
codim
,
colorbar
=
separate_colorbars
or
i
==
len
(
U
)
-
1
))
if
legend
:
ax
.
set_title
(
legend
[
i
])
# plt.tight_layout()
if
not
separate_colorbars
:
if
hasattr
(
plots
[
0
],
'p'
):
figure
.
colorbar
(
plots
[
0
].
p
,
ax
=
axes
)
def
set
(
self
,
U
,
ind
):
if
rescale_colorbars
:
if
separate_colorbars
:
...
...
@@ -130,6 +123,8 @@ def visualize_patch(grid, U, bounding_box=([0, 0], [1, 1]), codim=2, title=None,
def
__repr__
(
self
):
return
'
\n\n
'
.
join
(
repr
(
a
)
for
a
in
self
.
args
)
# otherwise the subplot displays twice
plt
.
close
(
plot
.
figure
)
return
concat_display
(
*
[
p
.
html
for
p
in
plot
.
plots
])
return
plot
...
...
src/pymor/discretizers/builtin/gui/matplotlib.py
View file @
fb65067d
...
...
@@ -46,29 +46,24 @@ class MatplotlibPatchAxes:
if
colorbar
:
figure
.
colorbar
(
self
.
p
,
ax
=
ax
)
delay_between_frames
=
500
# ms
# TODO blit=True
delay_between_frames
=
200
# ms
self
.
anim
=
animation
.
FuncAnimation
(
figure
,
self
.
set
,
frames
=
U
,
interval
=
delay_between_frames
,
blit
=
Fals
e
)
blit
=
Tru
e
)
# generating the HTML instance outside this class causes the plot display to fail
self
.
html
=
HTML
(
self
.
anim
.
to_jshtml
())
# otherwise the subplot displays twice
pyplot
.
close
(
figure
)
def
set
(
self
,
U
,
vmin
=
None
,
vmax
=
None
):
self
.
vmin
=
self
.
vmin
if
vmin
is
None
else
vmin
self
.
vmax
=
self
.
vmax
if
vmax
is
None
else
vmax
p
=
self
.
p
if
self
.
codim
==
2
:
p
.
set_array
(
U
)
self
.
p
.
set_array
(
U
)
elif
self
.
reference_element
is
triangle
:
p
.
set_array
(
U
)
self
.
p
.
set_array
(
U
)
else
:
p
.
set_array
(
np
.
tile
(
U
,
2
))
p
.
set_clim
(
self
.
vmin
,
self
.
vmax
)
return
(
p
,)
self
.
p
.
set_array
(
np
.
tile
(
U
,
2
))
self
.
p
.
set_clim
(
self
.
vmin
,
self
.
vmax
)
return
(
self
.
p
,)
class
Matplotlib1DAxes
:
...
...
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