Skip to content

Commit

Permalink
add plot_4d
Browse files Browse the repository at this point in the history
  • Loading branch information
cmbant committed Jun 4, 2021
1 parent 362eecd commit 8b881a5
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 248 deletions.
309 changes: 68 additions & 241 deletions docs/plot_gallery.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion getdist/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__author__ = 'Antony Lewis'
__version__ = "1.2.3"
__version__ = "1.3.0"
__url__ = "https://getdist.readthedocs.io"

from getdist.inifile import IniFile
Expand Down
13 changes: 7 additions & 6 deletions getdist/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3034,9 +3034,8 @@ def add_4d_scatter(self, root, params, ax, color_bar=False, max_scatter_points:
return x, y, z

def plot_4d(self, roots, params, color_bar=True, colorbar_args: Mapping = empty_dict,
ax=None, lims=empty_dict, azim: Optional[float] = 15, elev: Optional[float] = None,
alpha: Union[float, Sequence[float]] = 0.1, marker='o',
max_scatter_points: Optional[int] = None,
ax=None, lims=empty_dict, azim: Optional[float] = 15, elev: Optional[float] = None, dist: float = 11,
alpha: Union[float, Sequence[float]] = 0.1, marker='o', max_scatter_points: Optional[int] = None,
shadow_color=None, shadow_alpha=None, fixed_color=None, compare_colors=None,
animate=False, anim_angle_degrees=360, anim_step_degrees=0.6, anim_fps=15,
mp4_filename: Optional[str] = None, mp4_bitrate=-1, **kwargs):
Expand All @@ -3051,13 +3050,14 @@ def plot_4d(self, roots, params, color_bar=True, colorbar_args: Mapping = empty_
fixed_color and specify just three parameters
:param color_bar: True if should include a color bar
:param colorbar_args: extra arguments for colorbar
:param ax: optional :class:`~matplotlib:matplotlib.axes3d.Axes3D` instance
:param ax: optional :class:`~matplotlib:mpl_toolkits.mplot3d.axes3d.Axes3D` instance
to add to (defaults to current plot or the first/main plot if none)
:param lims: dictionary of optional limits, e.g. {'param1':(min1, max1),'param2':(min2,max2)}.
If this include parameters that are not plotted, the samples outside the limits will still be
removed
:param azim: azimuth for initial view
:param elev: elevation for initial view
:param dist: distance for view (make larger if labels out of area)
:param alpha: alpha, or list of alphas for each root, to use for scatter samples
:param marker: marker, or list of markers for each root
:param max_scatter_points: if set, maximum number of points to plots from each root
Expand All @@ -3074,7 +3074,7 @@ def plot_4d(self, roots, params, color_bar=True, colorbar_args: Mapping = empty_
:param anim_fps: animation frames per second
:param mp4_filename: if animating, optional filename to produce mp4 video
:param mp4_bitrate: bitrate
:param kwargs: additional optional arguments for :func:`~matplotlib:matplotlib.axes3d.Axes3D.scatter`
:param kwargs: additional optional arguments for :func:`~matplotlib:mpl_toolkits.mplot3d.axes3d.Axes3D.scatter`
.. plot::
:include-source:
Expand Down Expand Up @@ -3109,7 +3109,7 @@ def plot_4d(self, roots, params, color_bar=True, colorbar_args: Mapping = empty_
compare_colors=['k'],
animate=True, mp4_filename='sample_rotation.mp4', mp4_bitrate=1024, anim_fps=20)
See `sample output video <hhttps://cdn.cosmologist.info/antony/sample_rotation.mp4>`_.
See `sample output video <https://cdn.cosmologist.info/antony/sample_rotation.mp4>`_.
"""
roots = makeList(roots)
if not params:
Expand All @@ -3120,6 +3120,7 @@ def plot_4d(self, roots, params, color_bar=True, colorbar_args: Mapping = empty_
if not self.fig:
self.make_figure()
ax = self.subplots[0, 0] = Axes3D(self.fig)
ax.dist = dist
pts = []
for i, (root, alph, mark) in enumerate(extend_list_zip(roots, alpha, marker)):
pts.append(self.add_4d_scatter(root, params, ax, color_bar=not i and color_bar,
Expand Down

0 comments on commit 8b881a5

Please sign in to comment.