Skip to content

Commit aa72167

Browse files
hvasbathspringcoil
authored andcommitted
added cmap option to kde plots (#1500)
1 parent 113e720 commit aa72167

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pymc3/plots.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,11 @@ def make_2d(a):
150150
return a
151151

152152

153-
def kde2plot_op(ax, x, y, grid=200):
153+
def kde2plot_op(ax, x, y, grid=200, cmap=None):
154+
155+
if cmap is None:
156+
cmap =plt.cm.gist_earth_r
157+
154158
xmin = x.min()
155159
xmax = x.max()
156160
ymin = y.min()
@@ -163,7 +167,7 @@ def kde2plot_op(ax, x, y, grid=200):
163167
kernel = kde.gaussian_kde(values)
164168
Z = np.reshape(kernel(positions).T, X.shape)
165169

166-
ax.imshow(np.rot90(Z), cmap=plt.cm.gist_earth_r,
170+
ax.imshow(np.rot90(Z), cmap=cmap,
167171
extent=[xmin, xmax, ymin, ymax])
168172

169173

@@ -174,10 +178,10 @@ def kdeplot(data, ax=None):
174178
return ax
175179

176180

177-
def kde2plot(x, y, grid=200, ax=None):
181+
def kde2plot(x, y, grid=200, ax=None, cmap=None):
178182
if ax is None:
179183
f, ax = plt.subplots(1, 1, squeeze=True)
180-
kde2plot_op(ax, x, y, grid)
184+
kde2plot_op(ax, x, y, grid, cmap)
181185
return ax
182186

183187

0 commit comments

Comments
 (0)