Skip to content

Commit 33e3319

Browse files
committed
minor fixes to plotting
1 parent 7322bc5 commit 33e3319

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

RATapi/examples/bayes_benchmark/bayes_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def plot_marginalised_result(dimension: int, axes: plt.Axes, limits: tuple[float
355355

356356
if __name__ == "__main__":
357357
ns_2d, dream_2d, calc_2d = bayes_benchmark_2d(30)
358-
ns_3d, dream_3d, calc_3d = bayes_benchmark_3d(40)
358+
ns_3d, dream_3d, calc_3d = bayes_benchmark_3d(30)
359359

360360
plot_posterior_comparison(ns_2d, dream_2d, calc_2d)
361361
plot_posterior_comparison(ns_3d, dream_3d, calc_3d)

RATapi/utils/plotting.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def plot_corner(
443443
plot_one_hist(results, param=row_param, smooth=smooth, axes=current_axes, **hist_kwargs)
444444
elif i > j: # lower triangle: 2d histograms
445445
plot_contour(
446-
results, x_param=row_param, y_param=col_param, smooth=smooth, axes=current_axes, **hist2d_kwargs
446+
results, x_param=col_param, y_param=row_param, smooth=smooth, axes=current_axes, **hist2d_kwargs
447447
)
448448
elif i < j: # upper triangle: no plot
449449
current_axes.set_visible(False)
@@ -629,8 +629,7 @@ def plot_contour(
629629
default_settings = {"bins": 25, "density": True}
630630
hist2d_settings = {**default_settings, **hist2d_settings}
631631

632-
counts, y_bins, x_bins = np.histogram2d(results.chain[:, x_param], results.chain[:, y_param], **hist2d_settings)
633-
counts = counts.T # for some reason the counts given by numpy are sideways
632+
counts, x_bins, y_bins = np.histogram2d(results.chain[:, x_param], results.chain[:, y_param], **hist2d_settings)
634633
if smooth:
635634
if sigma is None:
636635
sigma_x = stdev(results.chain[:, x_param]) / 2
@@ -641,8 +640,8 @@ def plot_contour(
641640
counts = gaussian_filter1d(counts, axis=0, sigma=sigma_x)
642641
counts = gaussian_filter1d(counts, axis=1, sigma=sigma_y)
643642

644-
axes.pcolormesh(x_bins, y_bins, counts.max() - counts.T, cmap=matplotlib.colormaps["Greys"].reversed())
645-
axes.contour(x_bins[:-1], y_bins[:-1], counts.max() - counts.T, colors="black")
643+
axes.pcolormesh(x_bins, y_bins, counts.max() - counts, cmap=matplotlib.colormaps["Greys"].reversed())
644+
axes.contour(x_bins[:-1], y_bins[:-1], counts.max() - counts, colors="black")
646645
axes.set_xlabel(results.fitNames[x_param])
647646
axes.set_ylabel(results.fitNames[y_param])
648647

tests/test_plotting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ def test_contour(dream_results, x_param, y_param, hist2d_settings):
348348
y_param_chain = dream_results.chain[:, y_param_index]
349349
x_expected_range = (x_param_chain.min(), x_param_chain.max())
350350
y_expected_range = (y_param_chain.min(), y_param_chain.max())
351-
assert ax.get_xbound() == y_expected_range
352-
assert ax.get_ybound() == x_expected_range
351+
assert ax.get_xbound() == x_expected_range
352+
assert ax.get_ybound() == y_expected_range
353353

354354
# plt.close(fig)
355355

0 commit comments

Comments
 (0)