From 14f8c08da20be025bab55d3ff411ef6278743dd2 Mon Sep 17 00:00:00 2001
From: Klaus Rabbertz <klaus.rabbertz@cern.ch>
Date: Tue, 18 Jun 2024 04:10:50 +0200
Subject: [PATCH] More fixes for newer matplotlib

---
 tools/plotting/fastnnlo_scaleclosure.py | 5 +++--
 tools/plotting/fastnnlo_statunc.py      | 9 ++++++---
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/tools/plotting/fastnnlo_scaleclosure.py b/tools/plotting/fastnnlo_scaleclosure.py
index 82e80903..deddd171 100755
--- a/tools/plotting/fastnnlo_scaleclosure.py
+++ b/tools/plotting/fastnnlo_scaleclosure.py
@@ -394,8 +394,9 @@ a_fl2nn = np.divide(xs_fnll-xs_nnlo, xs_fnll+xs_nnlo,
 
 # Rel. stat. uncertainty from NNLOJET
 dst_nnlo = np.divide(dxs_nnlo, xs_nnlo, out=np.ones_like(dxs_nnlo), where=xs_nnlo != 0)
-dr_fl2nn = dstat*np.multiply(r_fl2nn, dst_nnlo)
-da_fl2nn = dstat*np.multiply(a_fl2nn, dst_nnlo)
+# errorbar yerr needs to be always positive in the new matplotlib versions
+dr_fl2nn = np.abs(dstat*np.multiply(r_fl2nn, dst_nnlo))
+da_fl2nn = np.abs(dstat*np.multiply(a_fl2nn, dst_nnlo))
 
 # Prepare plotting
 titwgt = 'bold'
diff --git a/tools/plotting/fastnnlo_statunc.py b/tools/plotting/fastnnlo_statunc.py
index 2b94f5dd..4b4bf3fa 100755
--- a/tools/plotting/fastnnlo_statunc.py
+++ b/tools/plotting/fastnnlo_statunc.py
@@ -132,8 +132,10 @@ def plotting(x_axis, xmin, xmax, dxsr_ch, dxsr_or, xlabel, ylabel, title, tablen
     ax1 = plt.subplot(gs[0, :])
     ax1.set_autoscalex_on(True)
     plt.setp(ax1.get_xticklabels(), visible=True)
-    ax1.set_xscale('log', nonposx='clip')
-    ax1.set_yscale('log', nonposy='clip')
+    #    ax1.set_xscale('log', nonposx='clip') # Will become nonpositive= in matplotlib 3.3.x
+    #    ax1.set_yscale('log', nonposy='clip') # Will become nonpositive= in matplotlib 3.3.x
+    ax1.set_xscale('log', nonpositive='clip')
+    ax1.set_yscale('log', nonpositive='clip')
     ax1.set_ylim(0.00001, 0.1)
     ax1.set_xlabel(r'%s' %xlabel, horizontalalignment='right', x=1.0, verticalalignment='top', y=1.0)
     ax1.set_ylabel(r'%s(%s)' % (ylabel, order), horizontalalignment='right', x=1.0,
@@ -178,7 +180,8 @@ def plotting(x_axis, xmin, xmax, dxsr_ch, dxsr_or, xlabel, ylabel, title, tablen
         ax2 = plt.subplot(gs2[0, :])
         ax2.set_autoscalex_on(True)
         plt.setp(ax2.get_xticklabels(), visible=True)
-        ax2.set_xscale('log', nonposx='clip')
+        #    ax2.set_xscale('log', nonposx='clip') # Will become nonpositive= in matplotlib 3.3.x
+        ax2.set_xscale('log', nonpositive='clip')
         ax2.set_ylim(-1.0, 1.5)
         ax2.set_xlabel(r'%s' %xlabel, horizontalalignment='right', x=1.0, verticalalignment='top', y=1.0)
         ax2.set_ylabel(r'%s(%s)' % (ylabel2, order), horizontalalignment='right', x=1.0,
-- 
GitLab