Skip to content

Commit f84842f

Browse files
committed
Add option to set y range.
1 parent 2a2e41b commit f84842f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

machine_learning_hep/utilities.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ def make_plot(name, path=None, suffix="eps", title="", size=None, margins_c=None
609609
list_obj=None, labels_obj=None,
610610
leg_pos=None, opt_leg_h="P", opt_leg_g="P", opt_plot_h="", opt_plot_g="P0",
611611
offsets_xy=None, maxdigits=3, colours=None, markers=None, sizes=None,
612-
range_x=None, margins_y=None, with_errors="xy", logscale=None):
612+
range_x=None, range_y=None, margins_y=None, with_errors="xy", logscale=None):
613613
"""
614614
Make a plot with objects from a list (list_obj).
615615
Returns a TCanvas and a list of other created ROOT objects.
@@ -621,7 +621,7 @@ def make_plot(name, path=None, suffix="eps", title="", size=None, margins_c=None
621621
- plotting of histograms (TH??), graphs (TGraph*), text fields (TLatex) and any other objects
622622
derived from TObject in any count and order
623623
- automatic calculation of plotting ranges (x, y) based on the data (histograms and graphs)
624-
- arbitrary x range
624+
- arbitrary x, y range
625625
- automatic style settings
626626
- optional plotting of the legend (enabled by providing the coordinates)
627627
- automatic adding of legend entries (in the plotting order)
@@ -641,6 +641,7 @@ def make_plot(name, path=None, suffix="eps", title="", size=None, margins_c=None
641641
- offsets of axis titles (offsets_xy), (format: [x, y])
642642
- maximum number of digits of the axis labels (maxdigits)
643643
- x range (range_x), (format: [x_min, x_max])
644+
- y range (range_y), (format: [y_min, y_max])
644645
- vertical margins between the horizontal axes and the data (margins_y), (format: [lower, upper]
645646
expressed as fractions of the total plotting range)
646647
- including the error bars in the range calculations (with_errors),
@@ -767,6 +768,7 @@ def is_latex(obj):
767768
list_h.append(obj)
768769
elif is_graph(obj):
769770
list_g.append(obj)
771+
770772
# get x range of histograms
771773
x_min_h, x_max_h = float("inf"), float("-inf")
772774
if len(list_h) > 0:
@@ -802,6 +804,8 @@ def is_latex(obj):
802804
y_min_plot, y_max_plot = y_min, y_max
803805
if isinstance(margins_y, list) and len(margins_y) == 2:
804806
y_min_plot, y_max_plot = get_plot_range(y_min, y_max, *margins_y, log_y)
807+
if isinstance(range_y, list) and len(range_y) == 2:
808+
y_min_plot, y_max_plot = range_y
805809

806810
# append "same" to the histogram plotting option if needed
807811
opt_plot_h = opt_plot_h.lower()

0 commit comments

Comments
 (0)