change colormap
makerscher opened this issue · comments
Hi,
I tried to change the colormap of the density plot in hist2d
import corner
import numpy as np
ndim, nsamples = 2, 10000
np.random.seed(42)
samples = np.random.randn(ndim * nsamples).reshape([nsamples, ndim])
figure = corner.hist2d(samples[:,0], samples[:,1], pcolor_kwargs={'cmap':'viridis'})
but I get the error message
File ~/anaconda3/lib/python3.10/site-packages/corner/core.py:668 in hist2d
ax.pcolor(X, Y, H.max() - H.T, cmap=density_cmap, **pcolor_kwargs)
TypeError: matplotlib.axes._axes.Axes.pcolor() got multiple values for keyword argument 'cmap'`
Is there another way to do this? In the end I would like to do something like
figure = corner.corner(samples, hist2d_kwargs={'cmap':'viridis'})
but with this the option is ignored.
The way that we construct color maps here is a little convoluted:
Lines 624 to 636 in cd9767f
and the key feature is that we want it (density_cmap
☝️) to fade to transparent at low density. This means that I don't love the idea of just allowing this to be replaced by another color map in general. I'd probably prefer taking the input color map and updating it to fade to transparent, but that's somewhat more tricky. In the meantime, you could try just updating density_cmap
with viridis
in the source to see if it looks good for your purposes!
Hi Dan,
thanks, now I see why you dont want it. I will try as you suggest.
Just a thought, if you use plot_datapoints=False, the fade to transparent is probably not needed?
That's right! Although I would expect it to still look "better" to fade instead of ending up with the color at the bottom of your color map - recognizing that that is totally subjective.