Commit 5861175f authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Fix plot routines when ndim=1

parent 27e12115
...@@ -785,6 +785,16 @@ class MCMCSearch(BaseSearchClass): ...@@ -785,6 +785,16 @@ class MCMCSearch(BaseSearchClass):
add_prior=False, nstds=None, label_offset=0.4, add_prior=False, nstds=None, label_offset=0.4,
dpi=300, rc_context={}, **kwargs): dpi=300, rc_context={}, **kwargs):
if self.ndim < 2:
with plt.rc_context(rc_context):
fig, ax = plt.subplots(figsize=figsize)
ax.hist(self.samples, bins=50, histtype='stepfilled')
ax.set_xlabel(self.theta_symbols[0])
fig.savefig('{}/{}_corner.png'.format(
self.outdir, self.label), dpi=dpi)
return
with plt.rc_context(rc_context): with plt.rc_context(rc_context):
fig, axes = plt.subplots(self.ndim, self.ndim, fig, axes = plt.subplots(self.ndim, self.ndim,
figsize=figsize) figsize=figsize)
...@@ -1008,9 +1018,15 @@ class MCMCSearch(BaseSearchClass): ...@@ -1008,9 +1018,15 @@ class MCMCSearch(BaseSearchClass):
if symbols: if symbols:
axes[i].set_ylabel(symbols[i]) axes[i].set_ylabel(symbols[i])
else: else:
axes[0].ticklabel_format(useOffset=False, axis='y')
cs = chain[:, :, temp].T cs = chain[:, :, temp].T
axes.plot(cs, color='k', alpha=alpha) if burnin_idx:
axes.ticklabel_format(useOffset=False, axis='y') axes[0].plot(idxs[:burnin_idx], cs[:burnin_idx],
color="r", alpha=alpha, lw=lw)
axes[0].plot(idxs[burnin_idx:], cs[burnin_idx:], color="k",
alpha=alpha, lw=lw)
if symbols:
axes[0].set_ylabel(symbols[0])
axes.append(fig.add_subplot(ndim+1, 1, ndim+1)) axes.append(fig.add_subplot(ndim+1, 1, ndim+1))
lnl = sampler.lnlikelihood[temp, :, :] lnl = sampler.lnlikelihood[temp, :, :]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment