Skip to content
Snippets Groups Projects
Commit 83c2f0d9 authored by Nikolai's avatar Nikolai
Browse files

Number of contour levels and log/lin scale configurable for plot_NN_vs_var_2D

parent 772956b7
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ import math ...@@ -5,6 +5,7 @@ import math
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import matplotlib.colors import matplotlib.colors
from matplotlib.ticker import LogFormatter
import numpy as np import numpy as np
import meme import meme
...@@ -43,7 +44,9 @@ def plot_NN_vs_var_2D(plotname, means, ...@@ -43,7 +44,9 @@ def plot_NN_vs_var_2D(plotname, means,
var2_index, var2_range, var2_index, var2_range,
var1_label=None, var1_label=None,
var2_label=None, var2_label=None,
contourdistance=0.1): logscale=False,
ncontours=20,
black_contourlines=False):
print("Creating varied events (2d)") print("Creating varied events (2d)")
# example: vary var1 vs var2 # example: vary var1 vs var2
...@@ -73,9 +76,19 @@ def plot_NN_vs_var_2D(plotname, means, ...@@ -73,9 +76,19 @@ def plot_NN_vs_var_2D(plotname, means,
zmin = np.min(scores) zmin = np.min(scores)
zmax = np.max(scores) zmax = np.max(scores)
# TODO: find out on how to set (in a reasonable way) the contour levels and z-axis ticks if logscale:
pcm = ax.contourf(sequence1, sequence2, scores, norm=matplotlib.colors.LogNorm(vmin=zmin, vmax=zmax)) lvls = np.logspace(math.log10(zmin), math.log10(zmax), ncontours)
cbar = fig.colorbar(pcm, ax=ax, extend='max') pcm = ax.contourf(sequence1, sequence2, scores, levels=lvls, norm=matplotlib.colors.LogNorm(vmin=zmin, vmax=zmax))
if black_contourlines:
ax.contour(sequence1, sequence2, scores, levels=lvls, colors="k", linewidths=1)
l_f = LogFormatter(10, labelOnlyBase=False, minor_thresholds=(np.inf, np.inf))
cbar = fig.colorbar(pcm, ax=ax, extend='max', ticks=lvls, format=l_f)
else:
pcm = ax.contourf(sequence1, sequence2, scores, ncontours, norm=matplotlib.colors.Normalize(vmin=0, vmax=1))
if black_contourlines:
ax.contour(sequence1, sequence2, scores, ncontours, colors="k", linewidths=1)
cbar = fig.colorbar(pcm, ax=ax, extend='max')
cbar.set_label("NN output") cbar.set_label("NN output")
if var1_label is not None: if var1_label is not None:
ax.set_xlabel(var1_label) ax.set_xlabel(var1_label)
...@@ -114,3 +127,4 @@ if __name__ == "__main__": ...@@ -114,3 +127,4 @@ if __name__ == "__main__":
var1_index=c.branches.index("met"), var1_range=(0, 1000, 10), var1_index=c.branches.index("met"), var1_range=(0, 1000, 10),
var2_index=c.branches.index("mt"), var2_range=(0, 500, 10), var2_index=c.branches.index("mt"), var2_range=(0, 500, 10),
var1_label="met [GeV]", var2_label="mt [GeV]") var1_label="met [GeV]", var2_label="mt [GeV]")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment