@@ -845,16 +845,30 @@ def multiROCCurveGreyOld(
845
845
plt .close ()
846
846
847
847
848
+ # th_colours = [
849
+ # "#36213E",
850
+ # "#9381FF",
851
+ # "#1f78b4",
852
+ # "#a6cee3",
853
+ # "#32965D",
854
+ # "#7CB518",
855
+ # "#EDB458",
856
+ # "#ff7f00",
857
+ # "#a70000",
858
+ # ]
859
+
860
+ # Updated with CMS color palette
848
861
th_colours = [
849
- "#36213E" ,
850
- # "#9381FF",
851
- "#1f78b4" ,
852
- "#a6cee3" ,
853
- # "#32965D",
854
- "#7CB518" ,
855
- "#EDB458" ,
856
- "#ff7f00" ,
857
- "#a70000" ,
862
+ "#3f90da" ,
863
+ "#ffa90e" ,
864
+ "#bd1f01" ,
865
+ "#94a4a2" ,
866
+ "#832db6" ,
867
+ "#a96b59" ,
868
+ "#e76300" ,
869
+ "#b9ac70" ,
870
+ "#717581" ,
871
+ "#92dadd" ,
858
872
]
859
873
860
874
@@ -1124,6 +1138,15 @@ def multiROCCurve(
1124
1138
# fontproperties="Tex Gyre Heros:bold",
1125
1139
)
1126
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
+
1127
1150
if kin_label :
1128
1151
ax .text (
1129
1152
0.05 ,
@@ -1329,3 +1352,83 @@ def cutsLinePlot(
1329
1352
plt .show ()
1330
1353
else :
1331
1354
plt .close ()
1355
+
1356
+
1357
+ def plot_hist (
1358
+ data ,
1359
+ sample_names ,
1360
+ plot_dir = "" ,
1361
+ name = "" ,
1362
+ nbins = 100 ,
1363
+ weights = None ,
1364
+ xlabel = None ,
1365
+ text = None ,
1366
+ xlim = None ,
1367
+ log = False ,
1368
+ density = False ,
1369
+ int_xticks = False ,
1370
+ lumi = None ,
1371
+ year = None ,
1372
+ com = 13.6 ,
1373
+ ):
1374
+ """Lightweight plotter for histograms.
1375
+ Args:
1376
+ data (list): List of data arrays to plot.
1377
+ sample_names (list): List of sample_names for each data array.
1378
+ nbins (int): Number of bins for the histogram.
1379
+ weights (list): List of weights for each data array.
1380
+ """
1381
+
1382
+ hep .style .use ("CMS" )
1383
+ colors = plt .cm .tab10 .colors
1384
+ fig , ax = plt .subplots (figsize = (12 , 9 ))
1385
+ hep .cms .label ("Preliminary" , data = True , lumi = lumi , year = year , com = com )
1386
+ if weights is not None :
1387
+ for d , w , sample_name , c in zip (data , weights , sample_names , colors [: len (data )]):
1388
+ ax .hist (
1389
+ d ,
1390
+ bins = nbins ,
1391
+ weights = w ,
1392
+ range = xlim ,
1393
+ label = sample_name ,
1394
+ color = c ,
1395
+ density = density ,
1396
+ log = log ,
1397
+ histtype = "step" ,
1398
+ linewidth = 2 ,
1399
+ )
1400
+ else :
1401
+ for d , sample_name , c in zip (data , sample_names , colors [: len (data )]):
1402
+ ax .hist (
1403
+ d ,
1404
+ bins = nbins ,
1405
+ range = xlim ,
1406
+ label = sample_name ,
1407
+ color = c ,
1408
+ density = density ,
1409
+ log = log ,
1410
+ histtype = "step" ,
1411
+ linewidth = 2 ,
1412
+ )
1413
+ if xlabel :
1414
+ ax .set_xlabel (xlabel )
1415
+ if text is not None :
1416
+ ax .text (
1417
+ 0.02 ,
1418
+ 0.6 ,
1419
+ text ,
1420
+ fontsize = 13 ,
1421
+ bbox = {"facecolor" : "white" , "edgecolor" : "black" },
1422
+ transform = ax .transAxes ,
1423
+ )
1424
+ if int_xticks :
1425
+ ax .xaxis .get_major_locator ().set_params (integer = True )
1426
+ ax .set_ylabel ("Normalized frequency" )
1427
+ ax .set_xlim (xlim )
1428
+ ax .legend ()
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
+
1434
+ plt .close ()
0 commit comments