From a40b1af4af8334308a8b1065c9389c176e9fd7fe Mon Sep 17 00:00:00 2001 From: pipme Date: Tue, 23 Aug 2022 11:53:55 +0300 Subject: [PATCH 1/2] Allow parsing cmap to contour plot. --- src/corner/core.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corner/core.py b/src/corner/core.py index 7f7ebc4..d1b36b5 100644 --- a/src/corner/core.py +++ b/src/corner/core.py @@ -700,7 +700,9 @@ def hist2d( if plot_contours: if contour_kwargs is None: contour_kwargs = dict() - contour_kwargs["colors"] = contour_kwargs.get("colors", color) + contour_kwargs["cmap"] = contour_kwargs.get("cmap", None) + if contour_kwargs["cmap"] is None: + contour_kwargs["colors"] = contour_kwargs.get("colors", color) ax.contour(X2, Y2, H2.T, V, **contour_kwargs) _set_xlim(new_fig, ax, range[0]) From 7dd52de4328898087e36e410ee0a572e2434e074 Mon Sep 17 00:00:00 2001 From: pipme Date: Tue, 11 Apr 2023 21:33:03 +0300 Subject: [PATCH 2/2] Fix mismatch between 1D marginal and 2D scatter plot when range is specified. --- src/corner/core.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/corner/core.py b/src/corner/core.py index d1b36b5..2d3cbfc 100644 --- a/src/corner/core.py +++ b/src/corner/core.py @@ -578,12 +578,13 @@ def hist2d( contour_cmap[i][-1] *= float(i) / (len(levels) + 1) # We'll make the 2D histogram to directly estimate the density. + range = list(map(np.sort, range)) try: H, X, Y = np.histogram2d( x.flatten(), y.flatten(), bins=bins, - range=list(map(np.sort, range)), + range=range, weights=weights, ) except ValueError: @@ -661,7 +662,15 @@ def hist2d( data_kwargs["ms"] = data_kwargs.get("ms", 2.0) data_kwargs["mec"] = data_kwargs.get("mec", "none") data_kwargs["alpha"] = data_kwargs.get("alpha", 0.1) - ax.plot(x, y, "o", zorder=-1, rasterized=True, **data_kwargs) + inds = ( + (x >= range[0][0]) + & (x <= range[0][1]) + & (y >= range[1][0]) + & (y <= range[1][1]) + ) + ax.plot( + x[inds], y[inds], "o", zorder=-1, rasterized=True, **data_kwargs + ) # Plot the base fill to hide the densest data points. if (plot_contours or plot_density) and not no_fill_contours: