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
44e55cd3
Commit
44e55cd3
authored
Jul 17, 2020
by
René Fritze
Committed by
René Fritze
Jul 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[vis] fix phantom axes disaply in animations
parent
b2c6a22a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
25 deletions
+25
-25
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
+20
-20
src/pymor/discretizers/builtin/gui/matplotlib.py
src/pymor/discretizers/builtin/gui/matplotlib.py
+4
-4
No files found.
notebooks/elliptic_oned.ipynb
View file @
44e55cd3
...
...
@@ -6,7 +6,7 @@
"metadata": {},
"outputs": [],
"source": [
"%matplotlib
notebook
"
"%matplotlib
inline
"
]
},
{
...
...
src/pymor/discretizers/builtin/gui/jupyter/matplotlib.py
View file @
44e55cd3
...
...
@@ -75,8 +75,6 @@ def visualize_patch(grid, U, bounding_box=([0, 0], [1, 1]), codim=2, title=None,
if
isinstance
(
legend
,
str
):
legend
=
(
legend
,)
assert
legend
is
None
or
isinstance
(
legend
,
tuple
)
and
len
(
legend
)
==
len
(
U
)
if
len
(
U
)
<
2
:
columns
=
1
class
Plot
:
...
...
@@ -97,21 +95,22 @@ 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
)
rows
=
int
(
np
.
ceil
(
len
(
U
)
/
columns
))
self
.
figure
=
figure
=
plt
.
figure
()
self
.
plots
=
plots
=
[]
axes
=
plt
.
subplots
(
nrows
=
rows
,
ncols
=
columns
,
squeeze
=
False
)
coord
=
itertools
.
product
(
range
(
rows
),
range
(
columns
))
for
i
,
(
vmin
,
vmax
,
u
,
c
)
in
enumerate
(
zip
(
self
.
vmins
,
self
.
vmaxs
,
U
,
coord
)):
ax
=
axes
[
c
]
plots
.
append
(
MatplotlibPatchAxes
(
U
=
u
,
ax
=
ax
,
figure
=
figure
,
grid
=
grid
,
bounding_box
=
bounding_box
,
vmin
=
vmin
,
vmax
=
vmax
,
# this _supposed_ to let animations run in sync
sync_timer
=
None
for
i
,
(
vmin
,
vmax
,
u
)
in
enumerate
(
zip
(
self
.
vmins
,
self
.
vmaxs
,
U
)):
figure
=
plt
.
figure
(
i
)
ax
=
plt
.
axes
()
sync_timer
=
sync_timer
or
figure
.
canvas
.
new_timer
()
plots
.
append
(
MatplotlibPatchAxes
(
U
=
u
,
ax
=
ax
,
figure
=
figure
,
sync_timer
=
sync_timer
,
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
()
plt
.
close
(
figure
)
def
set
(
self
,
U
,
ind
):
if
rescale_colorbars
:
...
...
@@ -128,8 +127,6 @@ def visualize_patch(grid, U, bounding_box=([0, 0], [1, 1]), codim=2, title=None,
plot
=
Plot
()
if
len
(
U
[
0
])
>
1
:
# otherwise the subplot displays twice
plt
.
close
(
plot
.
figure
)
return
concat_display
(
*
[
p
.
html
for
p
in
plot
.
plots
])
return
plot
...
...
@@ -209,20 +206,23 @@ def visualize_matplotlib_1d(grid, U, codim=1, title=None, legend=None, separate_
rows
=
int
(
np
.
ceil
(
len
(
U
)
/
columns
))
self
.
plots
=
[]
# this _supposed_ to let animations run in sync
sync_timer
=
None
self
.
figure
,
axes
=
plt
.
subplots
(
nrows
=
rows
,
ncols
=
columns
,
squeeze
=
False
)
coord
=
itertools
.
product
(
range
(
rows
),
range
(
columns
))
for
i
,
(
vmin
,
vmax
,
u
,
c
)
in
enumerate
(
zip
(
self
.
vmins
,
self
.
vmaxs
,
U
,
coord
)):
for
i
,
(
vmin
,
vmax
,
u
)
in
enumerate
(
zip
(
self
.
vmins
,
self
.
vmaxs
,
U
)):
count
=
1
if
not
separate_plots
:
count
=
len
(
U
[
0
])
ax
=
axes
[
c
]
self
.
plots
.
append
(
Matplotlib1DAxes
(
u
,
ax
,
self
.
figure
,
grid
,
count
,
vmin
=
vmin
,
vmax
=
vmax
,
figure
=
plt
.
figure
(
i
)
ax
=
plt
.
axes
()
sync_timer
=
sync_timer
or
figure
.
canvas
.
new_timer
()
self
.
plots
.
append
(
Matplotlib1DAxes
(
u
,
ax
,
figure
,
sync_timer
,
grid
,
count
,
vmin
=
vmin
,
vmax
=
vmax
,
codim
=
codim
))
if
legend
:
ax
.
set_title
(
legend
[
i
])
plt
.
tight_layout
()
plt
.
tight_layout
()
plt
.
close
(
figure
)
def
set
(
self
,
U
):
if
separate_plots
:
...
...
src/pymor/discretizers/builtin/gui/matplotlib.py
View file @
44e55cd3
...
...
@@ -18,7 +18,7 @@ from pymor.discretizers.builtin.grids.referenceelements import triangle, square
class
MatplotlibPatchAxes
:
def
__init__
(
self
,
U
,
ax
,
figure
,
grid
,
bounding_box
=
None
,
vmin
=
None
,
vmax
=
None
,
codim
=
2
,
def
__init__
(
self
,
U
,
ax
,
figure
,
sync_timer
,
grid
,
bounding_box
=
None
,
vmin
=
None
,
vmax
=
None
,
codim
=
2
,
colorbar
=
True
):
assert
grid
.
reference_element
in
(
triangle
,
square
)
assert
grid
.
dim
==
2
...
...
@@ -49,7 +49,7 @@ class MatplotlibPatchAxes:
delay_between_frames
=
200
# ms
self
.
anim
=
animation
.
FuncAnimation
(
figure
,
self
.
set
,
frames
=
U
,
interval
=
delay_between_frames
,
blit
=
True
)
blit
=
True
,
event_source
=
sync_timer
)
# generating the HTML instance outside this class causes the plot display to fail
self
.
html
=
HTML
(
self
.
anim
.
to_jshtml
())
...
...
@@ -68,7 +68,7 @@ class MatplotlibPatchAxes:
class
Matplotlib1DAxes
:
def
__init__
(
self
,
U
,
axes
,
figure
,
grid
,
count
,
vmin
=
None
,
vmax
=
None
,
codim
=
1
):
def
__init__
(
self
,
U
,
axes
,
figure
,
sync_timer
,
grid
,
count
,
vmin
=
None
,
vmax
=
None
,
codim
=
1
):
assert
isinstance
(
grid
,
OnedGrid
)
assert
codim
in
(
0
,
1
)
...
...
@@ -101,7 +101,7 @@ class Matplotlib1DAxes:
delay_between_frames
=
200
# ms
self
.
anim
=
animation
.
FuncAnimation
(
figure
,
self
.
set
,
frames
=
U
,
interval
=
delay_between_frames
,
blit
=
True
)
blit
=
True
,
event_source
=
sync_timer
)
# generating the HTML instance outside this class causes the plot display to fail
self
.
html
=
HTML
(
self
.
anim
.
to_jshtml
())
...
...
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