@@ -1138,6 +1138,15 @@ def multiROCCurve(
1138
1138
# fontproperties="Tex Gyre Heros:bold",
1139
1139
)
1140
1140
1141
+ # if 'auc' in roc:
1142
+ # ax.text(
1143
+ # 0.02,
1144
+ # 0.83,
1145
+ # f"AUC: {roc['auc']:.2f}",
1146
+ # transform=ax.transAxes,
1147
+ # fontsize=20,
1148
+ # )
1149
+
1141
1150
if kin_label :
1142
1151
ax .text (
1143
1152
0.05 ,
@@ -1347,11 +1356,12 @@ def cutsLinePlot(
1347
1356
1348
1357
def plot_hist (
1349
1358
data ,
1350
- names ,
1359
+ sample_names ,
1360
+ plot_dir = "" ,
1361
+ name = "" ,
1351
1362
nbins = 100 ,
1352
1363
weights = None ,
1353
1364
xlabel = None ,
1354
- saveas = None ,
1355
1365
text = None ,
1356
1366
xlim = None ,
1357
1367
log = False ,
@@ -1364,7 +1374,7 @@ def plot_hist(
1364
1374
"""Lightweight plotter for histograms.
1365
1375
Args:
1366
1376
data (list): List of data arrays to plot.
1367
- names (list): List of names for each data array.
1377
+ sample_names (list): List of sample_names for each data array.
1368
1378
nbins (int): Number of bins for the histogram.
1369
1379
weights (list): List of weights for each data array.
1370
1380
"""
@@ -1374,26 +1384,26 @@ def plot_hist(
1374
1384
fig , ax = plt .subplots (figsize = (12 , 9 ))
1375
1385
hep .cms .label ("Preliminary" , data = True , lumi = lumi , year = year , com = com )
1376
1386
if weights is not None :
1377
- for d , w , name , c in zip (data , weights , names , colors [: len (data )]):
1387
+ for d , w , sample_name , c in zip (data , weights , sample_names , colors [: len (data )]):
1378
1388
ax .hist (
1379
1389
d ,
1380
1390
bins = nbins ,
1381
1391
weights = w ,
1382
1392
range = xlim ,
1383
- label = name ,
1393
+ label = sample_name ,
1384
1394
color = c ,
1385
1395
density = density ,
1386
1396
log = log ,
1387
1397
histtype = "step" ,
1388
1398
linewidth = 2 ,
1389
1399
)
1390
1400
else :
1391
- for d , name , c in zip (data , names , colors [: len (data )]):
1401
+ for d , sample_name , c in zip (data , sample_names , colors [: len (data )]):
1392
1402
ax .hist (
1393
1403
d ,
1394
1404
bins = nbins ,
1395
1405
range = xlim ,
1396
- label = name ,
1406
+ label = sample_name ,
1397
1407
color = c ,
1398
1408
density = density ,
1399
1409
log = log ,
@@ -1416,7 +1426,9 @@ def plot_hist(
1416
1426
ax .set_ylabel ("Normalized frequency" )
1417
1427
ax .set_xlim (xlim )
1418
1428
ax .legend ()
1419
- if saveas :
1420
- plt .savefig (saveas , bbox_inches = "tight" )
1421
- print (f"saved figure as { saveas } " )
1429
+
1430
+ if len (name ):
1431
+ plt .savefig (f"{ plot_dir } /{ name } .pdf" , bbox_inches = "tight" )
1432
+ plt .savefig (f"{ plot_dir } /{ name } .png" , bbox_inches = "tight" )
1433
+
1422
1434
plt .close ()
0 commit comments