Skip to content

Commit

Permalink
Option to shade other than the first samples in 2D plots (#100)
Browse files Browse the repository at this point in the history
* Option to shade other than the first samples in 2D plots

Co-authored-by: Yves Kini <kiniyves@gmail.com>
Co-authored-by: Serena Vinciguerra <serena.vinciguerra89@gmail.com>

* Using bool/integer shaded-option instead of settings to select shade root

* Shaded condition simplified

---------

Co-authored-by: Yves Kini <kiniyves@gmail.com>
Co-authored-by: Serena Vinciguerra <serena.vinciguerra89@gmail.com>
  • Loading branch information
3 people committed Jun 9, 2023
1 parent 651b8c2 commit d070091
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions getdist/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,9 @@ def plot_2d(self, roots, param1=None, param2=None, param_pair=None, shaded=False
:param param1: x parameter name
:param param2: y parameter name
:param param_pair: An [x,y] pair of params; can be set instead of param1 and param2
:param shaded: True if plot should be a shaded density plot (for the first samples plotted)
:param shaded: True or integer if plot should be a shaded density plot, where the integer specifies
the index of which contour is shaded (first samples shaded if True provided instead
of an integer)
:param add_legend_proxy: True to add to the legend proxy
:param line_offset: line_offset if not adding first contours to plot
:param proxy_root_exclude: any root names not to include when adding to the legend proxy
Expand Down Expand Up @@ -1692,8 +1694,8 @@ def plot_2d(self, roots, param1=None, param2=None, param_pair=None, shaded=False
ax = self.get_axes(ax, pars=param_pair)
if self.settings.progress:
print('plotting: ', [param.name for param in param_pair])
if shaded and not kwargs.get('filled'):
self.add_2d_shading(roots[0], param_pair[0], param_pair[1], ax=ax)
if shaded is not False and not kwargs.get('filled'):
self.add_2d_shading(roots[0 if shaded is True else shaded], *param_pair, ax=ax)
xbounds, ybounds = None, None
contour_args = self._make_contour_args(len(roots), **kwargs)
for i, root in enumerate(roots):
Expand Down Expand Up @@ -2150,7 +2152,7 @@ def plots_2d(self, roots, param1=None, params2=None, param_pairs=None, nx=None,
:param label_order: minus one to show legends in reverse order that lines were added, or a list giving
specific order of line indices
:param filled: True to plot filled contours
:param shaded: True to shade by the density for the first root plotted
:param shaded: True to shade by the density for the first root plotted (unless specified otherwise)
:param kwargs: optional keyword arguments for :func:`~GetDistPlotter.plot_2d`
:return: The plot_col, plot_row subplot dimensions of the new figure
Expand Down Expand Up @@ -2324,7 +2326,7 @@ def triangle_plot(self, roots, params=None, legend_labels=None, plot_3d_with_par
:param plot_3d_with_param: for the 2D plots, make sample scatter plot, with samples colored by this parameter
name (to make a '3D' plot)
:param filled: True for filled contours
:param shaded: plot shaded density for first root (cannot be used with filled)
:param shaded: plot shaded density for first root (cannot be used with filled) unless specified otherwise
:param contour_args: optional dict (or list of dict) with arguments for each 2D plot
(e.g. specifying color, alpha, etc)
:param contour_colors: list of colors for plotting contours (for each root)
Expand Down

0 comments on commit d070091

Please sign in to comment.