Skip to content
Snippets Groups Projects
Unverified Commit 7574435a authored by Frank Sauerburger's avatar Frank Sauerburger
Browse files

Add y-axis scaling with multiple stacks and log-y

parent 1939b353
Branches 36-y-axis-scaling-in-histogram-plotting
No related tags found
1 merge request!29Checking if, y axis maximum needs to be scaled before doing so
Pipeline #12492 passed
......@@ -264,6 +264,7 @@ def hist(dataframe, variable, bins, stacks, selection=None,
denominator_hist = None
# Handle stack
max_content = float('-inf')
for i_stack, stack in enumerate(stacks):
if isinstance(stack, Process):
# Wrap single process
......@@ -323,6 +324,8 @@ def hist(dataframe, variable, bins, stacks, selection=None,
# (end of processes loop within a stack)
max_content = max(max_content, np.max(bottom))
if isinstance(numerator, int) and stacks[numerator] == stack:
numerator_hist = bottom
numerator_error = np.sqrt(sosw)
......@@ -341,6 +344,8 @@ def hist(dataframe, variable, bins, stacks, selection=None,
hatch='/////',
linewidth=0,
edgecolor="#666666")
max_content = max(max_content, np.max(bottom + np.sqrt(sosw) / 2))
# (end of stack loop)
# Handle ratio plot
if draw_ratio:
......@@ -446,12 +451,11 @@ def hist(dataframe, variable, bins, stacks, selection=None,
if y_log:
y_min = y_min if y_min is not None else 1
y_max *= 10**1.6
y_max = max([y_max, 10**1.6 * max_content])
axes.set_yscale('log')
else:
y_min = y_min if y_min is not None else 0
max_content = np.max(n)
y_max = max([y_max, 1.6*max_content])
y_max = max([y_max, 1.6 * max_content])
axes.set_ylim((y_min, y_max))
......
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