Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NIFTy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ift
NIFTy
Commits
386d2f0e
Commit
386d2f0e
authored
Sep 08, 2017
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first traces of new plotting
parent
102c7597
Pipeline
#17978
failed with stage
in 4 minutes and 11 seconds
Changes
36
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
144 additions
and
1333 deletions
+144
-1333
demos/wiener_filter_via_curvature.py
demos/wiener_filter_via_curvature.py
+5
-9
nifty2go/plotting/__init__.py
nifty2go/plotting/__init__.py
+1
-5
nifty2go/plotting/colormap/__init__.py
nifty2go/plotting/colormap/__init__.py
+0
-2
nifty2go/plotting/colormap/colormap.py
nifty2go/plotting/colormap/colormap.py
+0
-76
nifty2go/plotting/colormap/colormaps.py
nifty2go/plotting/colormap/colormaps.py
+0
-209
nifty2go/plotting/descriptors/__init__.py
nifty2go/plotting/descriptors/__init__.py
+0
-3
nifty2go/plotting/descriptors/axis.py
nifty2go/plotting/descriptors/axis.py
+0
-38
nifty2go/plotting/descriptors/line.py
nifty2go/plotting/descriptors/line.py
+0
-13
nifty2go/plotting/descriptors/marker.py
nifty2go/plotting/descriptors/marker.py
+0
-18
nifty2go/plotting/figures/__init__.py
nifty2go/plotting/figures/__init__.py
+0
-3
nifty2go/plotting/figures/figure_2D.py
nifty2go/plotting/figures/figure_2D.py
+0
-65
nifty2go/plotting/figures/figure_3D.py
nifty2go/plotting/figures/figure_3D.py
+0
-51
nifty2go/plotting/figures/figure_base.py
nifty2go/plotting/figures/figure_base.py
+0
-20
nifty2go/plotting/figures/figure_from_plot.py
nifty2go/plotting/figures/figure_from_plot.py
+0
-22
nifty2go/plotting/figures/multi_figure.py
nifty2go/plotting/figures/multi_figure.py
+0
-83
nifty2go/plotting/plot.py
nifty2go/plotting/plot.py
+138
-0
nifty2go/plotting/plotly_wrapper.py
nifty2go/plotting/plotly_wrapper.py
+0
-10
nifty2go/plotting/plots/__init__.py
nifty2go/plotting/plots/__init__.py
+0
-2
nifty2go/plotting/plots/heatmaps/__init__.py
nifty2go/plotting/plots/heatmaps/__init__.py
+0
-5
nifty2go/plotting/plots/heatmaps/glmollweide.py
nifty2go/plotting/plots/heatmaps/glmollweide.py
+0
-67
nifty2go/plotting/plots/heatmaps/heatmap.py
nifty2go/plotting/plots/heatmaps/heatmap.py
+0
-76
nifty2go/plotting/plots/heatmaps/hpmollweide.py
nifty2go/plotting/plots/heatmaps/hpmollweide.py
+0
-52
nifty2go/plotting/plots/heatmaps/mollweide_helper.py
nifty2go/plotting/plots/heatmaps/mollweide_helper.py
+0
-24
nifty2go/plotting/plots/scatter_plots/__init__.py
nifty2go/plotting/plots/scatter_plots/__init__.py
+0
-5
nifty2go/plotting/plots/scatter_plots/cartesian.py
nifty2go/plotting/plots/scatter_plots/cartesian.py
+0
-17
nifty2go/plotting/plots/scatter_plots/cartesian_2D.py
nifty2go/plotting/plots/scatter_plots/cartesian_2D.py
+0
-36
nifty2go/plotting/plots/scatter_plots/cartesian_3D.py
nifty2go/plotting/plots/scatter_plots/cartesian_3D.py
+0
-31
nifty2go/plotting/plots/scatter_plots/geo.py
nifty2go/plotting/plots/scatter_plots/geo.py
+0
-36
nifty2go/plotting/plots/scatter_plots/scatter_plot.py
nifty2go/plotting/plots/scatter_plots/scatter_plot.py
+0
-52
nifty2go/plotting/plotter/__init__.py
nifty2go/plotting/plotter/__init__.py
+0
-5
nifty2go/plotting/plotter/gl_plotter.py
nifty2go/plotting/plotter/gl_plotter.py
+0
-31
nifty2go/plotting/plotter/healpix_plotter.py
nifty2go/plotting/plotter/healpix_plotter.py
+0
-26
nifty2go/plotting/plotter/plotter_base.py
nifty2go/plotting/plotter/plotter_base.py
+0
-129
nifty2go/plotting/plotter/power_plotter.py
nifty2go/plotting/plotter/power_plotter.py
+0
-38
nifty2go/plotting/plotter/rg1d_plotter.py
nifty2go/plotting/plotter/rg1d_plotter.py
+0
-45
nifty2go/plotting/plotter/rg2d_plotter.py
nifty2go/plotting/plotter/rg2d_plotter.py
+0
-29
No files found.
demos/wiener_filter_via_curvature.py
View file @
386d2f0e
...
...
@@ -66,12 +66,8 @@ if __name__ == "__main__":
m
=
wiener_curvature
.
inverse_times
(
j
)
m_s
=
fft
(
m
)
plotter
=
ift
.
plotting
.
RG2DPlotter
()
plotter
.
path
=
'mock_signal.html'
plotter
(
mock_signal
.
real
)
plotter
.
path
=
'data.html'
plotter
(
ift
.
Field
(
signal_space
,
val
=
data
.
val
.
real
.
reshape
(
signal_space
.
shape
)))
plotter
.
path
=
'map.html'
plotter
(
m_s
.
real
)
ift
.
plotting
.
plot
(
mock_signal
.
real
,
"mock_signal.pdf"
)
ift
.
plotting
.
plot
(
mock_power
.
real
,
"power.pdf"
)
ift
.
plotting
.
plot
(
ift
.
Field
(
signal_space
,
val
=
data
.
val
.
real
.
reshape
(
signal_space
.
shape
)),
"data.pdf"
)
ift
.
plotting
.
plot
(
m_s
.
real
,
"map.pdf"
)
nifty2go/plotting/__init__.py
View file @
386d2f0e
from
.descriptors
import
*
from
.plots
import
*
from
.figures
import
*
from
.colormap
import
*
from
.plotter
import
*
from
.plot
import
plot
nifty2go/plotting/colormap/__init__.py
deleted
100644 → 0
View file @
102c7597
from
.colormap
import
Colormap
from
.
import
colormaps
nifty2go/plotting/colormap/colormap.py
deleted
100644 → 0
View file @
102c7597
from
__future__
import
division
from
builtins
import
str
from
..plotly_wrapper
import
PlotlyWrapper
class
Colormap
(
PlotlyWrapper
):
def
__init__
(
self
,
name
,
red
,
green
,
blue
):
self
.
name
=
name
self
.
red
=
red
self
.
green
=
green
self
.
blue
=
blue
def
validate_map
(
self
):
def
validade
(
m
):
#TODO: implement validation
pass
# no discontinuities only
@
staticmethod
def
from_matplotlib_colormap_internal
(
name
,
mpl_cmap
):
red
=
[(
c
[
0
],
c
[
2
])
for
c
in
mpl_cmap
[
'red'
]]
green
=
[(
c
[
0
],
c
[
2
])
for
c
in
mpl_cmap
[
'green'
]]
blue
=
[(
c
[
0
],
c
[
2
])
for
c
in
mpl_cmap
[
'blue'
]]
return
Colormap
(
name
,
red
,
green
,
blue
)
def
to_plotly
(
self
):
r
,
g
,
b
=
0
,
0
,
0
converted
=
list
()
prev_split
,
prev_r
,
prev_g
,
prev_b
=
0.
,
0.
,
0.
,
0.
while
prev_split
<
1
:
next_split
=
min
(
self
.
red
[
r
][
0
],
self
.
blue
[
b
][
0
],
self
.
green
[
g
][
0
])
if
next_split
==
self
.
red
[
r
][
0
]:
red_val
=
self
.
red
[
r
][
1
]
r
+=
1
else
:
slope
=
(
self
.
red
[
r
][
1
]
-
prev_r
)
/
(
self
.
red
[
r
][
0
]
-
prev_split
)
y
=
prev_r
-
slope
*
prev_split
red_val
=
slope
*
next_split
+
y
if
next_split
==
self
.
green
[
g
][
0
]:
green_val
=
self
.
green
[
g
][
1
]
g
+=
1
else
:
slope
=
((
self
.
green
[
g
][
1
]
-
prev_g
)
/
(
self
.
green
[
g
][
0
]
-
prev_split
))
y
=
prev_g
-
slope
*
prev_split
green_val
=
slope
*
next_split
+
y
if
next_split
==
self
.
blue
[
b
][
0
]:
blue_val
=
self
.
blue
[
b
][
1
]
b
+=
1
else
:
slope
=
((
self
.
blue
[
b
][
1
]
-
prev_b
)
/
(
self
.
blue
[
b
][
0
]
-
prev_split
))
y
=
prev_r
-
slope
*
prev_split
blue_val
=
slope
*
next_split
+
y
prev_split
=
next_split
prev_r
=
red_val
prev_g
=
green_val
prev_b
=
blue_val
converted
.
append
([
next_split
,
'rgb('
+
str
(
int
(
red_val
*
255
))
+
","
+
str
(
int
(
green_val
*
255
))
+
","
+
str
(
int
(
blue_val
*
255
))
+
")"
])
return
converted
nifty2go/plotting/colormap/colormaps.py
deleted
100644 → 0
View file @
102c7597
from
..colormap.colormap
import
Colormap
def
HighEnergyCmap
():
"""
Returns a color map often used in High Energy Astronomy.
"""
red
=
[(
0.0
,
0.0
),
(
0.167
,
0.0
),
(
0.333
,
0.5
),
(
0.5
,
1.0
),
(
0.667
,
1.0
),
(
0.833
,
1.0
),
(
1.0
,
1.0
)]
green
=
[(
0.0
,
0.0
),
(
0.167
,
0.0
),
(
0.333
,
0.0
),
(
0.5
,
0.0
),
(
0.667
,
0.5
),
(
0.833
,
1.0
),
(
1.0
,
1.0
)]
blue
=
[(
0.0
,
0.0
),
(
0.167
,
1.0
),
(
0.333
,
0.5
),
(
0.5
,
0.0
),
(
0.667
,
0.0
),
(
0.833
,
0.0
),
(
1.0
,
1.0
)]
return
Colormap
(
"High Energy"
,
red
,
green
,
blue
)
def
FaradayMapCmap
():
"""
Returns a color map used in reconstruction of the "Faraday Map".
References
----------
.. [#] N. Opermann et. al.,
"An improved map of the Galactic Faraday sky",
Astronomy & Astrophysics, Volume 542, id.A93, 06/2012;
`arXiv:1111.6186 <http://www.arxiv.org/abs/1111.6186>`_
"""
red
=
[(
0.0
,
0.35
),
(
0.1
,
0.4
),
(
0.2
,
0.25
),
(
0.41
,
0.47
),
(
0.5
,
0.8
),
(
0.56
,
0.96
),
(
0.59
,
1.0
),
(
0.74
,
0.8
),
(
0.8
,
0.8
),
(
0.9
,
0.5
),
(
1.0
,
0.4
)]
green
=
[(
0.0
,
0.0
),
(
0.2
,
0.0
),
(
0.362
,
0.88
),
(
0.5
,
1.0
),
(
0.638
,
0.88
),
(
0.8
,
0.25
),
(
0.9
,
0.3
),
(
1.0
,
0.2
)]
blue
=
[(
0.0
,
0.35
),
(
0.1
,
0.4
),
(
0.2
,
0.8
),
(
0.26
,
0.8
),
(
0.41
,
1.0
),
(
0.44
,
0.96
),
(
0.5
,
0.8
),
(
0.59
,
0.47
),
(
0.8
,
0.0
),
(
1.0
,
0.0
)]
return
Colormap
(
"Faraday Map"
,
red
,
green
,
blue
)
def
FaradayUncertaintyCmap
():
"""
Returns a color map used for the "Faraday Map Uncertainty".
References
----------
.. [#] N. Opermann et. al.,
"An improved map of the Galactic Faraday sky",
Astronomy & Astrophysics, Volume 542, id.A93, 06/2012;
`arXiv:1111.6186 <http://www.arxiv.org/abs/1111.6186>`_
"""
red
=
[(
0.0
,
1.0
),
(
0.1
,
0.8
),
(
0.2
,
0.65
),
(
0.41
,
0.6
),
(
0.5
,
0.7
),
(
0.56
,
0.96
),
(
0.59
,
1.0
),
(
0.74
,
0.8
),
(
0.8
,
0.8
),
(
0.9
,
0.5
),
(
1.0
,
0.4
)]
green
=
[(
0.0
,
0.9
),
(
0.2
,
0.65
),
(
0.362
,
0.95
),
(
0.5
,
1.0
),
(
0.638
,
0.88
),
(
0.8
,
0.25
),
(
0.9
,
0.3
),
(
1.0
,
0.2
)]
blue
=
[(
0.0
,
1.0
),
(
0.1
,
0.8
),
(
0.2
,
1.0
),
(
0.41
,
1.0
),
(
0.44
,
0.96
),
(
0.5
,
0.7
),
(
0.59
,
0.42
),
(
0.8
,
0.0
),
(
1.0
,
0.0
)]
return
Colormap
(
"Faraday Uncertainty"
,
red
,
green
,
blue
)
def
PlusMinusCmap
():
"""
Returns a color map useful for a zero-centerd range of values.
"""
red
=
[(
0.0
,
1.0
),
(
0.1
,
0.96
),
(
0.2
,
0.84
),
(
0.3
,
0.64
),
(
0.4
,
0.36
),
(
0.5
,
0.0
),
(
0.6
,
0.0
),
(
0.7
,
0.0
),
(
0.8
,
0.0
),
(
0.9
,
0.0
),
(
1.0
,
0.0
)]
green
=
[(
0.0
,
0.5
),
(
0.1
,
0.32
),
(
0.2
,
0.18
),
(
0.3
,
0.08
),
(
0.4
,
0.02
),
(
0.5
,
0.0
),
(
0.6
,
0.02
),
(
0.7
,
0.08
),
(
0.8
,
0.18
),
(
0.9
,
0.32
),
(
1.0
,
0.5
)]
blue
=
[(
0.0
,
0.0
),
(
0.1
,
0.0
),
(
0.2
,
0.0
),
(
0.3
,
0.0
),
(
0.4
,
0.0
),
(
0.5
,
0.0
),
(
0.6
,
0.36
),
(
0.7
,
0.64
),
(
0.8
,
0.84
),
(
0.9
,
0.96
),
(
1.0
,
1.0
)]
return
Colormap
(
"Plus Minus"
,
red
,
green
,
blue
)
def
PlankCmap
():
"""
Returns a color map similar to the one used for the "Planck CMB Map".
"""
red
=
[(
0.0
,
0.0
),
(
0.1
,
0.0
),
(
0.2
,
0.0
),
(
0.3
,
0.0
),
(
0.4
,
0.0
),
(
0.5
,
1.0
),
(
0.6
,
1.0
),
(
0.7
,
1.0
),
(
0.8
,
0.83
),
(
0.9
,
0.67
),
(
1.0
,
0.5
)]
green
=
[(
0.0
,
0.0
),
(
0.1
,
0.0
),
(
0.2
,
0.0
),
(
0.3
,
0.3
),
(
0.4
,
0.7
),
(
0.5
,
1.0
),
(
0.6
,
0.7
),
(
0.7
,
0.3
),
(
0.8
,
0.0
),
(
0.9
,
0.0
),
(
1.0
,
0.0
)]
blue
=
[(
0.0
,
0.5
),
(
0.1
,
0.67
),
(
0.2
,
0.83
),
(
0.3
,
1.0
),
(
0.4
,
1.0
),
(
0.5
,
1.0
),
(
0.6
,
0.0
),
(
0.7
,
0.0
),
(
0.8
,
0.0
),
(
0.9
,
0.0
),
(
1.0
,
0.0
)]
return
Colormap
(
"Planck-like"
,
red
,
green
,
blue
)
nifty2go/plotting/descriptors/__init__.py
deleted
100644 → 0
View file @
102c7597
from
.axis
import
Axis
from
.line
import
Line
from
.marker
import
Marker
nifty2go/plotting/descriptors/axis.py
deleted
100644 → 0
View file @
102c7597
# -*- coding: utf-8 -*-
from
..plotly_wrapper
import
PlotlyWrapper
class
Axis
(
PlotlyWrapper
):
def
__init__
(
self
,
label
=
None
,
font
=
'Balto'
,
color
=
''
,
log
=
False
,
font_size
=
22
,
show_grid
=
True
,
visible
=
True
):
self
.
label
=
str
(
label
)
if
label
is
not
None
else
None
self
.
font
=
font
self
.
color
=
color
self
.
log
=
log
self
.
font_size
=
int
(
font_size
)
self
.
show_grid
=
show_grid
self
.
visible
=
visible
def
to_plotly
(
self
):
ply_object
=
dict
()
if
self
.
label
:
ply_object
.
update
(
dict
(
title
=
self
.
label
,
titlefont
=
dict
(
family
=
self
.
font
,
color
=
self
.
color
,
size
=
self
.
font_size
)
))
if
self
.
log
:
ply_object
[
'type'
]
=
'log'
if
not
self
.
show_grid
:
ply_object
[
'showgrid'
]
=
False
ply_object
[
'visible'
]
=
self
.
visible
ply_object
[
'tickfont'
]
=
{
'size'
:
self
.
font_size
,
'family'
:
self
.
font
}
ply_object
[
'exponentformat'
]
=
'power'
# ply_object['domain'] = {'0': '0.04',
# '1': '1'}
return
ply_object
nifty2go/plotting/descriptors/line.py
deleted
100644 → 0
View file @
102c7597
# -*- coding: utf-8 -*-
from
..plotly_wrapper
import
PlotlyWrapper
class
Line
(
PlotlyWrapper
):
def
__init__
(
self
,
color
=
None
,
width
=
None
):
self
.
color
=
color
self
.
width
=
width
def
to_plotly
(
self
):
return
dict
(
color
=
self
.
color
,
width
=
self
.
width
)
nifty2go/plotting/descriptors/marker.py
deleted
100644 → 0
View file @
102c7597
# -*- coding: utf-8 -*-
from
..plotly_wrapper
import
PlotlyWrapper
class
Marker
(
PlotlyWrapper
):
# find symbols at: https://plot.ly/python/reference/#scatter-marker-symbol
def
__init__
(
self
,
color
=
None
,
size
=
None
,
symbol
=
None
,
opacity
=
None
):
self
.
color
=
color
self
.
size
=
size
self
.
symbol
=
symbol
self
.
opacity
=
opacity
def
to_plotly
(
self
):
return
dict
(
color
=
self
.
color
,
size
=
self
.
size
,
symbol
=
self
.
symbol
,
opacity
=
self
.
opacity
)
nifty2go/plotting/figures/__init__.py
deleted
100644 → 0
View file @
102c7597
from
.figure_2D
import
Figure2D
from
.figure_3D
import
Figure3D
from
.multi_figure
import
MultiFigure
nifty2go/plotting/figures/figure_2D.py
deleted
100644 → 0
View file @
102c7597
# -*- coding: utf-8 -*-
from
.figure_from_plot
import
FigureFromPlot
from
..plots
import
Heatmap
,
HPMollweide
,
GLMollweide
class
Figure2D
(
FigureFromPlot
):
def
__init__
(
self
,
plots
,
title
=
None
,
width
=
None
,
height
=
None
,
xaxis
=
None
,
yaxis
=
None
):
if
plots
is
not
None
:
width
=
width
if
width
is
not
None
else
plots
[
0
].
default_width
()
height
=
\
height
if
height
is
not
None
else
plots
[
0
].
default_height
()
xaxis
=
xaxis
if
xaxis
is
not
None
else
plots
[
0
].
default_axes
()[
0
]
yaxis
=
yaxis
if
yaxis
is
not
None
else
plots
[
0
].
default_axes
()[
1
]
if
isinstance
(
plots
[
0
],
Heatmap
)
and
width
is
None
and
\
height
is
None
:
(
y
,
x
)
=
plots
[
0
].
data
.
shape
width
=
500
height
=
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
super
(
Figure2D
,
self
).
__init__
(
plots
,
title
,
width
,
height
)
self
.
xaxis
=
xaxis
self
.
yaxis
=
yaxis
def
at
(
self
,
plots
,
title
=
None
):
title
=
title
if
title
is
not
None
else
self
.
title
return
Figure2D
(
plots
=
plots
,
title
=
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
:
plotly_object
[
'layout'
][
'xaxis'
]
=
self
.
xaxis
.
to_plotly
()
elif
not
self
.
xaxis
:
plotly_object
[
'layout'
][
'xaxis'
]
=
dict
(
autorange
=
True
,
showgrid
=
False
,
zeroline
=
False
,
showline
=
False
,
autotick
=
True
,
ticks
=
''
,
showticklabels
=
False
)
if
self
.
yaxis
:
plotly_object
[
'layout'
][
'yaxis'
]
=
self
.
yaxis
.
to_plotly
()
elif
not
self
.
yaxis
:
plotly_object
[
'layout'
][
'yaxis'
]
=
dict
(
showline
=
False
)
return
plotly_object
nifty2go/plotting/figures/figure_3D.py
deleted
100644 → 0
View file @
102c7597
# -*- coding: utf-8 -*-
from
.figure_from_plot
import
FigureFromPlot
class
Figure3D
(
FigureFromPlot
):
def
__init__
(
self
,
plots
,
title
=
None
,
width
=
None
,
height
=
None
,
xaxis
=
None
,
yaxis
=
None
,
zaxis
=
None
):
if
plots
is
not
None
:
width
=
width
if
width
is
not
None
else
plots
[
0
].
default_width
()
height
=
\
height
if
height
is
not
None
else
plots
[
0
].
default_height
()
xaxis
=
xaxis
if
xaxis
is
not
None
else
plots
[
0
].
default_axes
()[
0
]
yaxis
=
yaxis
if
yaxis
is
not
None
else
plots
[
0
].
default_axes
()[
1
]
zaxis
=
zaxis
if
zaxis
is
not
None
else
plots
[
0
].
default_axes
()[
2
]
super
(
Figure3D
,
self
).
__init__
(
plots
,
title
,
width
,
height
)
self
.
xaxis
=
xaxis
self
.
yaxis
=
yaxis
self
.
zaxis
=
zaxis
def
at
(
self
,
plots
,
title
=
None
):
title
=
title
if
title
is
not
None
else
self
.
title
return
Figure3D
(
plots
=
plots
,
title
=
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
:
plotly_object
[
'layout'
][
'scene'
][
'aspectratio'
]
=
dict
()
if
self
.
xaxis
:
plotly_object
[
'layout'
][
'scene'
][
'xaxis'
]
=
self
.
xaxis
.
to_plotly
()
elif
not
self
.
xaxis
:
plotly_object
[
'layout'
][
'scene'
][
'xaxis'
]
=
dict
(
showline
=
False
)
if
self
.
yaxis
:
plotly_object
[
'layout'
][
'scene'
][
'yaxis'
]
=
self
.
yaxis
.
to_plotly
()
elif
not
self
.
yaxis
:
plotly_object
[
'layout'
][
'scene'
][
'yaxis'
]
=
dict
(
showline
=
False
)
if
self
.
zaxis
:
plotly_object
[
'layout'
][
'scene'
][
'zaxis'
]
=
self
.
zaxis
.
to_plotly
()
elif
not
self
.
zaxis
:
plotly_object
[
'layout'
][
'scene'
][
'zaxis'
]
=
dict
(
showline
=
False
)
return
plotly_object
nifty2go/plotting/figures/figure_base.py
deleted
100644 → 0
View file @
102c7597
# -*- coding: utf-8 -*-
import
abc
from
..plotly_wrapper
import
PlotlyWrapper
class
FigureBase
(
PlotlyWrapper
):
def
__init__
(
self
,
title
,
width
,
height
):
self
.
title
=
title
self
.
width
=
width
self
.
height
=
height
@
abc
.
abstractmethod
def
at
(
self
,
title
=
None
):
raise
NotImplementedError
@
abc
.
abstractmethod
def
to_plotly
(
self
):
raise
NotImplementedError
nifty2go/plotting/figures/figure_from_plot.py
deleted
100644 → 0
View file @
102c7597
# -*- coding: utf-8 -*-
from
.figure_base
import
FigureBase
class
FigureFromPlot
(
FigureBase
):
def
__init__
(
self
,
plots
,
title
,
width
,
height
):
super
(
FigureFromPlot
,
self
).
__init__
(
title
,
width
,
height
)
self
.
plots
=
plots
def
to_plotly
(
self
):
data
=
[
plt
.
to_plotly
()
for
plt
in
self
.
plots
]
layout
=
{
'title'
:
self
.
title
,
'scene'
:
{
'aspectmode'
:
'cube'
},
'autosize'
:
False
,
'width'
:
self
.
width
,
'height'
:
self
.
height
,
}
plotly_object
=
{
'data'
:
data
,
'layout'
:
layout
}
return
plotly_object
nifty2go/plotting/figures/multi_figure.py
deleted
100644 → 0
View file @
102c7597
# -*- coding: utf-8 -*-
from
builtins
import
map
from
builtins
import
str
import
numpy
as
np
from
.figure_base
import
FigureBase
from
.figure_3D
import
Figure3D
import
plotly
# TODO: add nice height and width defaults for multifigure
class
MultiFigure
(
FigureBase
):
def
__init__
(
self
,
subfigures
,
title
=
None
,
width
=
None
,
height
=
None
):
super
(
MultiFigure
,
self
).
__init__
(
title
,
width
,
height
)
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
):
return
self
.
subfigures
.
shape
[
0
]
@
property
def
columns
(
self
):
return
self
.
subfigures
.
shape
[
1
]
def
to_plotly
(
self
):
title_extractor
=
lambda
z
:
z
.
title
if
z
else
""
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
)))
multi_figure_plotly_object
=
plotly
.
tools
.
make_subplots
(
self
.
rows
,
self
.
columns
,