Commit 2a76f09b authored by connor.hainje@pnnl.gov's avatar connor.hainje@pnnl.gov
Browse files

Flip y-axis on 2D plots

parent 4742384b
......@@ -88,14 +88,14 @@ def subplot_blame_2D(ax, df, detector="max", color_list=None, cell_fontsize=10):
idx = np.argmin(blames, 2) if detector == "min" else np.argmax(blames, 2)
val = np.take_along_axis(blames, np.expand_dims(idx, 2), 2).squeeze()
vmax = len(const.DETECTORS) - 0.5
im = ax.imshow(idx, cmap=cmap, vmin=-0.5, vmax=vmax, aspect="auto")
im = ax.imshow(idx, cmap=cmap, vmin=-0.5, vmax=vmax, aspect="auto", origin="lower")
connected_region_borders(ax, idx)
elif detector in const.DETECTORS:
index = const.DETECTORS.index(detector)
cmap = colors.make_linear_colormap(color_list[index])
val = blames[:, :, index]
im = ax.imshow(val, cmap=cmap, aspect="auto")
im = ax.imshow(val, cmap=cmap, aspect="auto", origin="lower")
else:
raise ValueError("detector not understood")
......
......@@ -141,7 +141,7 @@ def subplot_avg_contribution_2D(ax, df, det="max", color_list=None, cell_fontsiz
for (i, j), g in gb:
val[i, j] = g.mean()[f"contrib_{det}"]
im = ax.imshow(val, cmap=cmap, aspect="auto")
im = ax.imshow(val, cmap=cmap, aspect="auto", origin="lower")
# add cell values
if cell_fontsize > 0:
......@@ -163,7 +163,7 @@ def subplot_avg_contribution_2D(ax, df, det="max", color_list=None, cell_fontsiz
# TODO: make sure vlims are correct
im = ax.imshow(
idx, cmap=cmap, vmin=-0.5, vmax=len(const.DETECTORS) - 0.5, aspect="auto"
idx, cmap=cmap, vmin=-0.5, vmax=len(const.DETECTORS) - 0.5, aspect="auto", origin="lower"
)
# add cell values
......
......@@ -194,7 +194,7 @@ def _subplot_2D(
vmax = len(const.PARTICLES) - 0.5
else:
vmin, vmax = vlims
im = ax.imshow(idx, cmap=cmap, vmin=vmin, vmax=vmax, aspect="auto")
im = ax.imshow(idx, cmap=cmap, vmin=vmin, vmax=vmax, aspect="auto", origin="lower")
connected_region_borders(ax, idx)
elif particle in const.PARTICLES:
......@@ -208,7 +208,7 @@ def _subplot_2D(
else:
vmin, vmax = vlims
im = ax.imshow(val, cmap=cmap, vmin=vmin, vmax=vmax, aspect="auto")
im = ax.imshow(val, cmap=cmap, vmin=vmin, vmax=vmax, aspect="auto", origin="lower")
else:
raise ValueError("particle not understood")
......
......@@ -346,7 +346,7 @@ def subplot_efficiency_diff(ax, df1, df2, particle=None, cmap="RdBu", cbar=False
eff2 = compute_efficiency_in_all_bins(df2, particle=particle)
diff = eff1 - eff2
lim = np.amax(np.abs(diff))
im = ax.imshow(diff, cmap=cmap, vmin=-lim, vmax=+lim)
im = ax.imshow(diff, cmap=cmap, vmin=-lim, vmax=+lim, origin="lower")
if cbar:
plt.colorbar(im, ax=ax)
add_p_theta_axis_labels(ax)
......@@ -428,7 +428,7 @@ def subplot_auc_diff(ax, df1, df2, particle=None, cmap="RdBu", cbar=False):
auc2 = compute_auc_in_all_bins(df2, particle=particle)
diff = auc1 - auc2
lim = np.amax(np.abs(diff))
im = ax.imshow(diff, cmap=cmap, vmin=-lim, vmax=+lim)
im = ax.imshow(diff, cmap=cmap, vmin=-lim, vmax=+lim, origin="lower")
if cbar:
plt.colorbar(im, ax=ax)
add_p_theta_axis_labels(ax)
......@@ -471,7 +471,7 @@ def subplot_top_wrong(
cmap = colors.make_colormap(color_list, detectors=False)
wrong, freq = compute_top_wrong_in_all_bins(df)
ax.imshow(wrong, cmap=cmap, vmin=0, vmax=len(const.PARTICLES))
ax.imshow(wrong, cmap=cmap, vmin=0, vmax=len(const.PARTICLES), origin="lower")
hatches = [".", "-", "/", "|", "\\", "x"]
ec = (0, 0, 0, hatch_alpha)
......@@ -618,7 +618,7 @@ def subplot_blame(ax, df, color_list=None, celltextsize=10):
cmap = colors.make_colormap(color_list)
cmap.set_bad(color="white")
blame, freq = compute_blame_in_all_bins(df)
ax.imshow(blame, cmap=cmap, vmin=0, vmax=len(const.DETECTORS))
ax.imshow(blame, cmap=cmap, vmin=0, vmax=len(const.DETECTORS), origin="lower")
add_p_theta_axis_labels(ax)
text_array_values(ax, freq, fontsize=celltextsize)
# kwargs = dict(ha="center", va="center", fontsize=celltextsize)
......
Supports Markdown
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