Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
4b11da0d
Commit
4b11da0d
authored
May 19, 2017
by
Theo Steininger
Browse files
Refactored plotting classes.
parent
ad8d2948
Pipeline
#12650
passed with stage
in 4 minutes and 24 seconds
Changes
18
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty/plotting/figures/figure_2D.py
View file @
4b11da0d
...
...
@@ -7,31 +7,44 @@ from nifty.plotting.plots import Heatmap, HPMollweide, GLMollweide
class
Figure2D
(
FigureFromPlot
):
def
__init__
(
self
,
plots
,
title
=
None
,
width
=
None
,
height
=
None
,
xaxis
=
None
,
yaxis
=
None
):
super
(
Figure2D
,
self
).
__init__
(
plots
,
title
,
width
,
height
)
# TODO: add sanitization of plots input
if
isinstance
(
plots
[
0
],
Heatmap
)
and
not
width
and
not
height
:
(
x
,
y
)
=
plots
[
0
].
data
.
shape
if
plots
is
not
None
:
if
isinstance
(
plots
[
0
],
Heatmap
)
and
width
is
None
and
\
height
is
None
:
(
x
,
y
)
=
plots
[
0
].
data
.
shape
if
x
>
y
:
width
=
500
height
=
int
(
500
*
y
/
x
)
else
:
height
=
500
width
=
int
(
500
*
y
/
x
)
if
isinstance
(
plots
[
0
],
GLMollweide
)
or
\
isinstance
(
plots
[
0
],
HPMollweide
):
xaxis
=
False
if
(
xaxis
is
None
)
else
xaxis
yaxis
=
False
if
(
yaxis
is
None
)
else
yaxis
if
x
>
y
:
width
=
500
height
=
int
(
500
*
y
/
x
)
else
:
height
=
500
width
=
int
(
500
*
y
/
x
)
if
isinstance
(
plots
[
0
],
GLMollweide
)
or
isinstance
(
plots
[
0
],
HPMollweide
):
if
not
xaxis
:
xaxis
=
False
if
not
yaxis
:
yaxis
=
False
width
=
None
height
=
None
super
(
Figure2D
,
self
).
__init__
(
plots
,
title
,
width
,
height
)
self
.
xaxis
=
xaxis
self
.
yaxis
=
yaxis
def
at
(
self
,
plots
):
return
Figure2D
(
plots
=
plots
,
title
=
self
.
title
,
width
=
self
.
width
,
height
=
self
.
height
,
xaxis
=
self
.
xaxis
,
yaxis
=
self
.
yaxis
)
def
to_plotly
(
self
):
plotly_object
=
super
(
Figure2D
,
self
).
to_plotly
()
if
self
.
xaxis
or
self
.
yaxis
:
plotly_object
[
'layout'
][
'scene'
][
'aspectratio'
]
=
{}
if
self
.
xaxis
:
...
...
nifty/plotting/figures/figure_3D.py
View file @
4b11da0d
...
...
@@ -10,6 +10,15 @@ class Figure3D(FigureFromPlot):
self
.
yaxis
=
yaxis
self
.
zaxis
=
zaxis
def
at
(
self
,
plots
):
return
Figure3D
(
plots
=
plots
,
title
=
self
.
title
,
width
=
self
.
width
,
height
=
self
.
height
,
xaxis
=
self
.
xaxis
,
yaxis
=
self
.
yaxis
,
zaxis
=
self
.
zaxis
)
def
to_plotly
(
self
):
plotly_object
=
super
(
Figure3D
,
self
).
to_plotly
()
if
self
.
xaxis
or
self
.
yaxis
or
self
.
zaxis
:
...
...
nifty/plotting/figures/figure_base.py
View file @
4b11da0d
# -*- coding: utf-8 -*-
from
abc
import
abstractmethod
import
abc
from
nifty.plotting.plotly_wrapper
import
PlotlyWrapper
...
...
@@ -11,6 +11,10 @@ class FigureBase(PlotlyWrapper):
self
.
width
=
width
self
.
height
=
height
@
abstractmethod
@
abc
.
abstractmethod
def
at
(
self
):
raise
NotImplementedError
@
abc
.
abstractmethod
def
to_plotly
(
self
):
raise
NotImplementedError
nifty/plotting/figures/multi_figure.py
View file @
4b11da0d
...
...
@@ -10,13 +10,21 @@ plotly = gdi.get('plotly')
# TODO: add nice height and width defaults for multifigure
class
MultiFigure
(
FigureBase
):
def
__init__
(
self
,
rows
,
columns
,
title
=
None
,
width
=
None
,
height
=
None
,
subfigures
=
None
):
def
__init__
(
self
,
subfigures
,
title
=
None
,
width
=
None
,
height
=
None
):
if
'plotly'
not
in
gdi
:
raise
ImportError
(
"The module plotly is needed but not available."
)
super
(
MultiFigure
,
self
).
__init__
(
title
,
width
,
height
)
self
.
subfigures
=
np
.
empty
((
rows
,
columns
),
dtype
=
np
.
object
)
self
.
subfigures
[:]
=
subfigures
if
subfigures
is
not
None
:
self
.
subfigures
=
np
.
asarray
(
subfigures
,
dtype
=
np
.
object
)
if
len
(
self
.
subfigures
.
shape
)
!=
2
:
raise
ValueError
(
"Subfigures must be a two-dimensional array."
)
def
at
(
self
,
subfigures
):
return
MultiFigure
(
subfigures
=
subfigures
,
title
=
self
.
title
,
width
=
self
.
width
,
height
=
self
.
height
)
@
property
def
rows
(
self
):
...
...
@@ -26,15 +34,15 @@ class MultiFigure(FigureBase):
def
columns
(
self
):
return
self
.
subfigures
.
shape
[
1
]
def
add_subfigure
(
self
,
figure
,
row
,
column
):
self
.
subfigures
[
row
,
column
]
=
figure
def
to_plotly
(
self
):
title_extractor
=
lambda
z
:
z
.
title
if
z
else
""
sub_titles
=
tuple
(
np
.
vectorize
(
title_extractor
)(
self
.
subfigures
.
flatten
()))
sub_titles
=
tuple
(
np
.
vectorize
(
title_extractor
)(
self
.
subfigures
.
flatten
()))
specs_setter
=
lambda
z
:
{
'is_3d'
:
True
}
if
isinstance
(
z
,
Figure3D
)
else
{}
sub_specs
=
list
(
map
(
list
,
np
.
vectorize
(
specs_setter
)(
self
.
subfigures
)))
specs_setter
=
lambda
z
:
({
'is_3d'
:
True
}
if
isinstance
(
z
,
Figure3D
)
else
{})
sub_specs
=
list
(
map
(
list
,
np
.
vectorize
(
specs_setter
)(
self
.
subfigures
)))
multi_figure_plotly_object
=
plotly
.
tools
.
make_subplots
(
self
.
rows
,
...
...
@@ -46,7 +54,7 @@ class MultiFigure(FigureBase):
width
=
self
.
width
,
title
=
self
.
title
)
#TODO resolve bug with titles and 3D subplots
#
TODO resolve bug with titles and 3D subplots
i
=
1
for
index
,
fig
in
np
.
ndenumerate
(
self
.
subfigures
):
...
...
nifty/plotting/plots/heatmaps/glmollweide.py
View file @
4b11da0d
...
...
@@ -10,16 +10,26 @@ pyHealpix = gdi.get('pyHealpix')
class
GLMollweide
(
Heatmap
):
def
__init__
(
self
,
data
,
nlat
,
nlon
,
color_map
=
None
,
webgl
=
False
,
smoothing
=
False
):
# smoothing 'best', 'fast', False
def
__init__
(
self
,
data
,
xsize
=
800
,
color_map
=
None
,
webgl
=
False
,
smoothing
=
False
):
# smoothing 'best', 'fast', False
if
'pyHealpix'
not
in
gdi
:
raise
ImportError
(
"The module pyHealpix is needed but not available."
)
self
.
xsize
=
xsize
super
(
GLMollweide
,
self
).
__init__
(
data
,
color_map
,
webgl
,
smoothing
)
def
at
(
self
,
data
):
if
isinstance
(
data
,
list
):
data
=
[
self
.
_mollview
(
d
)
for
d
in
data
]
else
:
data
=
self
.
_mollview
(
data
,
nlat
,
nlon
)
super
(
GLMollweide
,
self
).
__init__
(
data
,
color_map
,
webgl
,
smoothing
)
data
=
self
.
_mollview
(
data
)
return
GLMollweide
(
data
=
data
,
xsize
=
self
.
xsize
,
color_map
=
self
.
color_map
,
webgl
=
self
.
webgl
,
smoothing
=
self
.
smoothing
)
@
staticmethod
def
_find_closest
(
A
,
target
):
...
...
@@ -31,10 +41,13 @@ class GLMollweide(Heatmap):
idx
-=
target
-
left
<
right
-
target
return
idx
def
_mollview
(
self
,
x
,
nlat
,
nlon
,
xsize
=
800
):
def
_mollview
(
self
,
x
):
xsize
=
self
.
xsize
nlat
=
x
.
shape
[
0
]
nlon
=
x
.
shape
[
1
]
res
,
mask
,
theta
,
phi
=
mollweide_helper
(
xsize
)
x
=
np
.
reshape
(
x
,
(
nlat
,
nlon
))
ra
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
nlon
+
1
)
dec
=
pyHealpix
.
GL_thetas
(
nlat
)
ilat
=
self
.
_find_closest
(
dec
,
theta
)
...
...
nifty/plotting/plots/heatmaps/heatmap.py
View file @
4b11da0d
...
...
@@ -6,14 +6,8 @@ from nifty.plotting.plotly_wrapper import PlotlyWrapper
class
Heatmap
(
PlotlyWrapper
):
def
__init__
(
self
,
data
,
color_map
=
None
,
webgl
=
False
,
smoothing
=
False
):
# smoothing 'best', 'fast', False
if
isinstance
(
data
,
list
):
self
.
data
=
np
.
zeros
((
data
[
0
].
shape
))
for
arr
in
data
:
self
.
data
=
np
.
add
(
self
.
data
,
arr
)
else
:
self
.
data
=
data
def
__init__
(
self
,
data
,
color_map
=
None
,
webgl
=
False
,
smoothing
=
False
):
# smoothing 'best', 'fast', False
if
color_map
is
not
None
:
if
not
isinstance
(
color_map
,
Colormap
):
...
...
@@ -22,6 +16,19 @@ class Heatmap(PlotlyWrapper):
self
.
color_map
=
color_map
self
.
webgl
=
webgl
self
.
smoothing
=
smoothing
self
.
data
=
data
def
at
(
self
,
data
):
if
isinstance
(
data
,
list
):
temp_data
=
np
.
zeros
((
data
[
0
].
shape
))
for
arr
in
data
:
temp_data
=
np
.
add
(
temp_data
,
arr
)
else
:
temp_data
=
data
return
Heatmap
(
data
=
temp_data
,
color_map
=
self
.
color_map
,
webgl
=
self
.
webgl
,
smoothing
=
self
.
smoothing
)
@
property
def
figure_dimension
(
self
):
...
...
@@ -29,7 +36,9 @@ class Heatmap(PlotlyWrapper):
def
to_plotly
(
self
):
plotly_object
=
dict
()
plotly_object
[
'z'
]
=
self
.
data
plotly_object
[
'showscale'
]
=
False
if
self
.
color_map
:
plotly_object
[
'colorscale'
]
=
self
.
color_map
.
to_plotly
()
...
...
nifty/plotting/plots/heatmaps/hpmollweide.py
View file @
4b11da0d
...
...
@@ -10,18 +10,27 @@ pyHealpix = gdi.get('pyHealpix')
class
HPMollweide
(
Heatmap
):
def
__init__
(
self
,
data
,
color_map
=
None
,
webgl
=
False
,
def
__init__
(
self
,
data
,
xsize
=
800
,
color_map
=
None
,
webgl
=
False
,
smoothing
=
False
):
# smoothing 'best', 'fast', False
if
'pyHealpix'
not
in
gdi
:
raise
ImportError
(
"The module pyHealpix is needed but not available."
)
self
.
xsize
=
xsize
super
(
HPMollweide
,
self
).
__init__
(
data
,
color_map
,
webgl
,
smoothing
)
def
at
(
self
,
data
):
if
isinstance
(
data
,
list
):
data
=
[
self
.
_mollview
(
d
)
for
d
in
data
]
else
:
data
=
self
.
_mollview
(
data
)
super
(
HPMollweide
,
self
).
__init__
(
data
,
color_map
,
webgl
,
smoothing
)
return
HPMollweide
(
data
=
data
,
xsize
=
self
.
xsize
,
color_map
=
self
.
color_map
,
webgl
=
self
.
webgl
,
smoothing
=
self
.
smoothing
)
def
_mollview
(
self
,
x
,
xsize
=
800
):
def
_mollview
(
self
,
x
):
xsize
=
self
.
xsize
res
,
mask
,
theta
,
phi
=
mollweide_helper
(
xsize
)
ptg
=
np
.
empty
((
phi
.
size
,
2
),
dtype
=
np
.
float64
)
...
...
nifty/plotting/plots/scatter_plots/cartesian.py
View file @
4b11da0d
...
...
@@ -4,16 +4,14 @@ from scatter_plot import ScatterPlot
class
Cartesian
(
ScatterPlot
):
def
__init__
(
self
,
x
,
y
,
label
,
line
,
marker
,
showlegend
=
True
):
super
(
Cartesian
,
self
).
__init__
(
label
,
line
,
marker
)
self
.
x
=
x
self
.
y
=
y
def
__init__
(
self
,
data
,
label
,
line
,
marker
,
showlegend
=
True
):
super
(
Cartesian
,
self
).
__init__
(
data
,
label
,
line
,
marker
)
self
.
showlegend
=
showlegend
@
abstractmethod
def
to_plotly
(
self
):
plotly_object
=
super
(
Cartesian
,
self
).
to_plotly
()
plotly_object
[
'x'
]
=
self
.
x
plotly_object
[
'y'
]
=
self
.
y
plotly_object
[
'x'
]
=
self
.
data
[
0
]
plotly_object
[
'y'
]
=
self
.
data
[
1
]
plotly_object
[
'showlegend'
]
=
self
.
showlegend
return
plotly_object
nifty/plotting/plots/scatter_plots/cartesian_2D.py
View file @
4b11da0d
...
...
@@ -4,17 +4,20 @@ from cartesian import Cartesian
class
Cartesian2D
(
Cartesian
):
def
__init__
(
self
,
x
=
None
,
y
=
None
,
x_start
=
0
,
x_step
=
1
,
label
=
''
,
line
=
None
,
marker
=
None
,
showlegend
=
True
,
def
__init__
(
self
,
data
,
label
=
''
,
line
=
None
,
marker
=
None
,
showlegend
=
True
,
webgl
=
True
):
if
y
is
None
:
raise
Exception
(
'Error: no y data to plot'
)
if
x
is
None
:
x
=
range
(
x_start
,
len
(
y
)
*
x_step
,
x_step
)
super
(
Cartesian2D
,
self
).
__init__
(
x
,
y
,
label
,
line
,
marker
,
super
(
Cartesian2D
,
self
).
__init__
(
data
,
label
,
line
,
marker
,
showlegend
)
self
.
webgl
=
webgl
def
at
(
self
,
data
):
return
Cartesian2D
(
data
=
data
,
label
=
self
.
label
,
line
=
self
.
line
,
marker
=
self
.
marker
,
showlegend
=
self
.
showlegend
,
webgl
=
self
.
webgl
)
@
property
def
figure_dimension
(
self
):
return
2
...
...
nifty/plotting/plots/scatter_plots/cartesian_3D.py
View file @
4b11da0d
...
...
@@ -4,11 +4,17 @@ from cartesian import Cartesian
class
Cartesian3D
(
Cartesian
):
def
__init__
(
self
,
x
,
y
,
z
,
label
=
''
,
line
=
None
,
marker
=
None
,
def
__init__
(
self
,
data
,
label
=
''
,
line
=
None
,
marker
=
None
,
showlegend
=
True
):
super
(
Cartesian3D
,
self
).
__init__
(
x
,
y
,
label
,
line
,
marker
,
super
(
Cartesian3D
,
self
).
__init__
(
data
,
label
,
line
,
marker
,
showlegend
)
self
.
z
=
z
def
at
(
self
,
data
):
return
Cartesian3D
(
data
=
data
,
label
=
self
.
label
,
line
=
self
.
line
,
marker
=
self
.
marker
,
showlegend
=
self
.
showlegend
)
@
property
def
figure_dimension
(
self
):
...
...
@@ -16,6 +22,6 @@ class Cartesian3D(Cartesian):
def
to_plotly
(
self
):
plotly_object
=
super
(
Cartesian3D
,
self
).
to_plotly
()
plotly_object
[
'z'
]
=
self
.
z
plotly_object
[
'z'
]
=
self
.
data
[
2
]
plotly_object
[
'type'
]
=
'scatter3d'
return
plotly_object
nifty/plotting/plots/scatter_plots/geo.py
View file @
4b11da0d
...
...
@@ -3,26 +3,31 @@ from scatter_plot import ScatterPlot
class
Geo
(
ScatterPlot
):
def
__init__
(
self
,
lon
,
l
at
,
label
=
''
,
line
=
None
,
marker
=
None
,
proj
=
'mollweide'
):
def
__init__
(
self
,
d
at
a
,
label
=
''
,
line
=
None
,
marker
=
None
,
proj
ection
=
'mollweide'
):
"""
proj: mollweide or mercator
"""
super
.
__init__
(
label
,
line
,
marker
)
self
.
lon
=
lon
self
.
lat
=
lat
self
.
projection
=
proj
super
(
Geo
,
self
).
__init__
(
label
,
line
,
marker
)
self
.
projection
=
projection
def
at
(
self
,
data
):
return
Geo
(
data
=
data
,
label
=
self
.
label
,
line
=
self
.
line
,
marker
=
self
.
marker
,
projection
=
self
.
projection
)
@
property
def
figure_dimension
(
self
):
return
2
def
_to_plotly
(
self
):
def
_to_plotly
(
self
,
data
):
plotly_object
=
super
(
Geo
,
self
).
to_plotly
()
plotly_object
[
'type'
]
=
'scattergeo'
plotly_object
[
'lon'
]
=
self
.
lon
plotly_object
[
'lat'
]
=
self
.
lat
plotly_object
[
'type'
]
=
self
.
projection
plotly_object
[
'lon'
]
=
data
[
0
]
plotly_object
[
'lat'
]
=
data
[
1
]
if
self
.
line
:
plotly_object
[
'mode'
]
=
'lines'
return
plotly_object
nifty/plotting/plots/scatter_plots/scatter_plot.py
View file @
4b11da0d
...
...
@@ -7,7 +7,8 @@ from nifty.plotting.descriptors import Marker,\
class
ScatterPlot
(
PlotlyWrapper
):
def
__init__
(
self
,
label
,
line
,
marker
):
def
__init__
(
self
,
data
,
label
,
line
,
marker
):
self
.
data
=
data
self
.
label
=
label
self
.
line
=
line
self
.
marker
=
marker
...
...
@@ -15,6 +16,10 @@ class ScatterPlot(PlotlyWrapper):
self
.
marker
=
Marker
()
self
.
line
=
Line
()
@
abc
.
abstractmethod
def
at
(
self
,
data
):
raise
NotImplementedError
@
abc
.
abstractproperty
def
figure_dimension
(
self
):
raise
NotImplementedError
...
...
nifty/plotting/plotter/__init__.py
View file @
4b11da0d
...
...
@@ -2,3 +2,4 @@
from
healpix_plotter
import
HealpixPlotter
from
gl_plotter
import
GLPlotter
from
power_plotter
import
PowerPlotter
from
rg2d_plotter
import
RG2DPlotter
nifty/plotting/plotter/gl_plotter.py
View file @
4b11da0d
import
numpy
as
np
from
nifty.spaces
import
GLSpace
from
nifty.plotting.figures
import
Figure2D
from
nifty.plotting.plots
import
GLMollweide
from
.plotter
import
Plotter
from
.plotter
_base
import
Plotter
Base
class
GLPlotter
(
Plotter
):
class
GLPlotter
(
Plotter
Base
):
def
__init__
(
self
,
interactive
=
False
,
path
=
'.'
,
title
=
""
,
color_map
=
None
):
super
(
GLPlotter
,
self
).
__init__
(
interactive
,
path
,
title
)
self
.
color_map
=
color_map
super
(
GLPlotter
,
self
).
__init__
(
interactive
,
path
,
title
)
@
property
def
domain_classes
(
self
):
return
(
GLSpace
,
)
def
_create_individual_figure
(
self
,
plots
):
return
Figure2D
(
plots
)
def
_create_individual_plot
(
self
,
data
,
plot_domain
):
result_plot
=
GLMollweide
(
data
=
data
,
nlat
=
plot_domain
[
0
].
nlat
,
nlon
=
plot_domain
[
0
].
nlon
,
def
_initialize_plot
(
self
):
result_plot
=
GLMollweide
(
data
=
None
,
color_map
=
self
.
color_map
)
return
result_plot
def
_initialize_figure
(
self
):
return
Figure2D
(
plots
=
None
)
def
_parse_data
(
self
,
data
,
field
,
spaces
):
gl_space
=
field
.
domain
[
spaces
[
0
]]
data
=
np
.
reshape
(
data
,
(
gl_space
.
nlat
,
gl_space
.
nlon
))
return
data
nifty/plotting/plotter/healpix_plotter.py
View file @
4b11da0d
...
...
@@ -2,22 +2,22 @@ from nifty.spaces import HPSpace
from
nifty.plotting.figures
import
Figure2D
from
nifty.plotting.plots
import
HPMollweide
from
.plotter
import
Plotter
from
.plotter
_base
import
Plotter
Base
class
HealpixPlotter
(
Plotter
):
class
HealpixPlotter
(
Plotter
Base
):
def
__init__
(
self
,
interactive
=
False
,
path
=
'.'
,
title
=
""
,
color_map
=
None
):
super
(
HealpixPlotter
,
self
).
__init__
(
interactive
,
path
,
title
)
self
.
color_map
=
color_map
super
(
HealpixPlotter
,
self
).
__init__
(
interactive
,
path
,
title
)
@
property
def
domain_classes
(
self
):
return
(
HPSpace
,
)
def
_create_individual_figure
(
self
,
plots
):
return
Figure2D
(
plots
)
def
_create_individual_plot
(
self
,
data
,
plot_domain
):
result_plot
=
HPMollweide
(
data
=
data
,
def
_initialize_plot
(
self
):
result_plot
=
HPMollweide
(
data
=
None
,
color_map
=
self
.
color_map
)
return
result_plot
def
_initialize_figure
(
self
):
return
Figure2D
(
plots
=
None
)
nifty/plotting/plotter/plotter.py
→
nifty/plotting/plotter/plotter
_base
.py
View file @
4b11da0d
...
...
@@ -27,7 +27,7 @@ rank = d2o.config.dependency_injector[
d2o
.
configuration
[
'mpi_module'
]].
COMM_WORLD
.
rank
class
Plotter
(
Loggable
,
object
):
class
Plotter
Base
(
Loggable
,
object
):
__metaclass__
=
abc
.
ABCMeta
def
__init__
(
self
,
interactive
=
False
,
path
=
'.'
,
title
=
""
):
...
...
@@ -37,6 +37,10 @@ class Plotter(Loggable, object):
self
.
path
=
path
self
.
title
=
str
(
title
)
self
.
plot
=
self
.
_initialize_plot
()
self
.
figure
=
self
.
_initialize_figure
()
self
.
multi_figure
=
self
.
_initialize_multifigure
()
@
abc
.
abstractproperty
def
domain_classes
(
self
):
return
(
Space
,)
...
...
@@ -57,7 +61,7 @@ class Plotter(Loggable, object):
def
path
(
self
,
new_path
):
self
.
_path
=
os
.
path
.
normpath
(
new_path
)
def
plot
(
self
,
fields
,
spaces
=
None
,
data_extractor
=
None
,
labels
=
None
):
def
__call__
(
self
,
fields
,
spaces
=
None
,
data_extractor
=
None
,
labels
=
None
):
if
isinstance
(
fields
,
Field
):
fields
=
[
fields
]
elif
not
isinstance
(
fields
,
list
):
...
...
@@ -82,12 +86,12 @@ class Plotter(Loggable, object):
plots_list
=
[]
for
slice_list
in
utilities
.
get_slice_list
(
data_list
[
0
].
shape
,
axes
):
plots_list
+=
\
[[
self
.
_create_individual_plot
(
current_data
[
slice_list
],
plot_domain
)
for
current_data
in
data_list
]]
[[
self
.
plot
.
at
(
self
.
_parse_data
(
current_data
,
field
,
spaces
))
for
(
current_data
,
field
)
in
zip
(
data_list
,
fields
)]]
figures
=
[
self
.
_create_individual_figure
(
plots
)
for
plots
in
plots_list
]
figures
=
[
self
.
figure
.
at
(
plots
)
for
plots
in
plots_list
]
self
.
_finalize_figure
(
figures
)
...
...
@@ -103,13 +107,16 @@ class Plotter(Loggable, object):
return
data
@
abc
.
abstractmethod
def
_
create_individual_figure
(
self
,
plots
):
def
_
initialize_plot
(
self
):
raise
NotImplementedError
@
abc
.
abstractmethod
def
_
create_individual_plot
(
self
,
data
,
fields
):
def
_
initialize_figure
(
self
):
raise
NotImplementedError
def
_initialize_multifigure
(
self
):
return
MultiFigure
(
subfigures
=
None
)
def
_finalize_figure
(
self
,
figures
):
if
len
(
figures
)
>
1
:
rows
=
(
len
(
figures
)
+
1
)
//
2
...
...
@@ -117,9 +124,7 @@ class Plotter(Loggable, object):
figure_array
[:
len
(
figures
)]
=
figures
figure_array
=
figure_array
.
reshape
((
2
,
rows
))
final_figure
=
MultiFigure
(
rows
,
2
,
title
=
'Test'
,
subfigures
=
figure_array
)
final_figure
=
self
.
multi_figure
(
subfigures
=
figure_array
)
else
:
final_figure
=
figures
[
0
]
...
...
nifty/plotting/plotter/power_plotter.py
View file @
4b11da0d
# -*- coding: utf-8 -*-
import
numpy
as
np
from
nifty.spaces
import
PowerSpace
from
nifty.plotting.descriptors
import
Axis
from
nifty.plotting.figures
import
Figure2D
from
nifty.plotting.plots
import
Cartesian2D
from
.plotter
import
Plotter
from
.plotter
_base
import
Plotter
Base