From 91ba4c2c3813025eb195a26fe32725a34d0dc715 Mon Sep 17 00:00:00 2001 From: Bruce Howard <61521590+brucehoward-physics@users.noreply.github.com> Date: Sat, 30 Mar 2024 11:18:47 -0500 Subject: [PATCH 1/2] Add Work In Progress labels along with additional options for placements of the Prelim and Work In Prog tags in the axis. --- icarusplot.py | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/icarusplot.py b/icarusplot.py index e5ae3d1..c77d6b7 100644 --- a/icarusplot.py +++ b/icarusplot.py @@ -29,6 +29,26 @@ def useGrayscale(): ####################### ## Plot labeling +def ICARUSMCWip(_axis,_locRight=False): + _yrange = _axis.get_ylim() + _use_y = _yrange[1] + 0.025*(_yrange[1] - _yrange[0]) + _xrange = _axis.get_xlim() + if _locRight==True: + _use_x = _xrange[1] - 0.025*(_xrange[1] - _xrange[0]) + return _axis.text( x=_use_x, y=_use_y, s=r'$\bf{ICARUS}$ Simulation Work In Progress', fontsize=14, color='blue', horizontalalignment='right' ) + _use_x = _xrange[0] + 0.025*(_xrange[1] - _xrange[0]) + return _axis.text( x=_use_x, y=_use_y, s=r'$\bf{ICARUS}$ Simulation Work In Progress', fontsize=14, color='blue' ) + +def ICARUSDataWip(_axis,_locRight=False): + _yrange = _axis.get_ylim() + _use_y = _yrange[1] + 0.025*(_yrange[1] - _yrange[0]) + _xrange = _axis.get_xlim() + if _locRight==True: + _use_x = _xrange[1] - 0.025*(_xrange[1] - _xrange[0]) + return _axis.text( x=_use_x, y=_use_y, s=r'$\bf{ICARUS}$ Data Work In Progress', fontsize=14, color='#d67a11', horizontalalignment='right' ) + _use_x = _xrange[0] + 0.025*(_xrange[1] - _xrange[0]) + return _axis.text( x=_use_x, y=_use_y, s=r'$\bf{ICARUS}$ Data Work In Progress', fontsize=14, color='#d67a11' ) + def ICARUSMCPreliminary(_axis,_locRight=False): _yrange = _axis.get_ylim() _use_y = _yrange[1] + 0.025*(_yrange[1] - _yrange[0]) @@ -78,8 +98,54 @@ def POT(_axis,_pot): return _axis.text( x=_use_x, y=_use_y, s='{:0.2}'.format(_use_pot)+r'$\times 10^{20}$'+' POT',\ fontsize=13, color='black', horizontalalignment='right' ) +def WorkInProgress(_axis,_loc='upper left'): + if _loc!='upper left' and _loc!='upper right' and _loc!='upper middle' and _loc!='lower middle' and _loc!='lower left' and _loc!='lower right': + print('Invalid location for W.I.P. tag given. Choose upper left, upper right, upper middle, or lower middle.') + elif _loc=='upper left': + _yrange = _axis.get_ylim() + _use_y = _yrange[1] - 0.5*(_yrange[1] - _yrange[0]) + _xrange = _axis.get_xlim() + _use_x = _xrange[0] + 0.05*(_xrange[1] - _xrange[0]) + return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='gray',weight='bold', + fontsize=20,alpha=0.6,rotation=40.) + elif _loc=='upper right': + _yrange = _axis.get_ylim() + _use_y = _yrange[1] - 0.5*(_yrange[1] - _yrange[0]) + _xrange = _axis.get_xlim() + _use_x = _xrange[1] - 0.05*(_xrange[1] - _xrange[0]) + return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='gray',weight='bold', + fontsize=20,alpha=0.6,rotation=-40.,horizontalalignment='right') + elif _loc=='upper middle': + _yrange = _axis.get_ylim() + _use_y = _yrange[1] - 0.1*(_yrange[1] - _yrange[0]) + _xrange = _axis.get_xlim() + _use_x = _xrange[1] - 0.5*(_xrange[1] - _xrange[0]) + return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='gray',weight='bold', + fontsize=20,alpha=0.6,horizontalalignment='center') + elif _loc=='lower left': + _yrange = _axis.get_ylim() + _use_y = _yrange[0] + 0.1*(_yrange[1] - _yrange[0]) + _xrange = _axis.get_xlim() + _use_x = _xrange[0] + 0.05*(_xrange[1] - _xrange[0]) + return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='gray',weight='bold', + fontsize=20,alpha=0.6) + elif _loc=='lower right': + _yrange = _axis.get_ylim() + _use_y = _yrange[0] + 0.1*(_yrange[1] - _yrange[0]) + _xrange = _axis.get_xlim() + _use_x = _xrange[1] - 0.05*(_xrange[1] - _xrange[0]) + return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='gray',weight='bold', + fontsize=20,alpha=0.6,horizontalalignment='right') + else: + _yrange = _axis.get_ylim() + _use_y = _yrange[0] + 0.1*(_yrange[1] - _yrange[0]) + _xrange = _axis.get_xlim() + _use_x = _xrange[1] - 0.5*(_xrange[1] - _xrange[0]) + return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='white',weight='bold', + fontsize=20,alpha=0.6,horizontalalignment='center') + def Preliminary(_axis,_loc='upper left'): - if _loc!='upper left' and _loc!='upper right' and _loc!='upper middle' and _loc!='lower middle': + if _loc!='upper left' and _loc!='upper right' and _loc!='upper middle' and _loc!='lower middle' and _loc!='lower left' and _loc!='lower right': print('Invalid location for PRELMINARY tag given. Choose upper left, upper right, upper middle, or lower middle.') elif _loc=='upper left': _yrange = _axis.get_ylim() @@ -102,6 +168,20 @@ def Preliminary(_axis,_loc='upper left'): _use_x = _xrange[1] - 0.5*(_xrange[1] - _xrange[0]) return _axis.text(s='PRELIMINARY',x=_use_x,y=_use_y,color='gray',weight='bold', fontsize=20,alpha=0.6,horizontalalignment='center') + elif _loc=='lower left': + _yrange = _axis.get_ylim() + _use_y = _yrange[1] - 0.1*(_yrange[1] - _yrange[0]) + _xrange = _axis.get_xlim() + _use_x = _xrange[0] + 0.05*(_xrange[1] - _xrange[0]) + return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='gray',weight='bold', + fontsize=20,alpha=0.6) + elif _loc=='lower right': + _yrange = _axis.get_ylim() + _use_y = _yrange[1] - 0.1*(_yrange[1] - _yrange[0]) + _xrange = _axis.get_xlim() + _use_x = _xrange[1] - 0.05*(_xrange[1] - _xrange[0]) + return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='gray',weight='bold', + fontsize=20,alpha=0.6,horizontalalignment='right') else: _yrange = _axis.get_ylim() _use_y = _yrange[0] + 0.1*(_yrange[1] - _yrange[0]) From a2ca54013700d1f726f958dadf67bdc43dec030a Mon Sep 17 00:00:00 2001 From: Bruce Howard <61521590+brucehoward-physics@users.noreply.github.com> Date: Mon, 1 Apr 2024 12:04:43 -0500 Subject: [PATCH 2/2] update to allow variable text size in Prelim/Work In Prog labels --- icarusplot.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/icarusplot.py b/icarusplot.py index c77d6b7..e087806 100644 --- a/icarusplot.py +++ b/icarusplot.py @@ -98,7 +98,7 @@ def POT(_axis,_pot): return _axis.text( x=_use_x, y=_use_y, s='{:0.2}'.format(_use_pot)+r'$\times 10^{20}$'+' POT',\ fontsize=13, color='black', horizontalalignment='right' ) -def WorkInProgress(_axis,_loc='upper left'): +def WorkInProgress(_axis,_loc='upper left',_size=20): if _loc!='upper left' and _loc!='upper right' and _loc!='upper middle' and _loc!='lower middle' and _loc!='lower left' and _loc!='lower right': print('Invalid location for W.I.P. tag given. Choose upper left, upper right, upper middle, or lower middle.') elif _loc=='upper left': @@ -107,44 +107,44 @@ def WorkInProgress(_axis,_loc='upper left'): _xrange = _axis.get_xlim() _use_x = _xrange[0] + 0.05*(_xrange[1] - _xrange[0]) return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='gray',weight='bold', - fontsize=20,alpha=0.6,rotation=40.) + fontsize=_size,alpha=0.6,rotation=40.) elif _loc=='upper right': _yrange = _axis.get_ylim() _use_y = _yrange[1] - 0.5*(_yrange[1] - _yrange[0]) _xrange = _axis.get_xlim() _use_x = _xrange[1] - 0.05*(_xrange[1] - _xrange[0]) return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='gray',weight='bold', - fontsize=20,alpha=0.6,rotation=-40.,horizontalalignment='right') + fontsize=_size,alpha=0.6,rotation=-40.,horizontalalignment='right') elif _loc=='upper middle': _yrange = _axis.get_ylim() _use_y = _yrange[1] - 0.1*(_yrange[1] - _yrange[0]) _xrange = _axis.get_xlim() _use_x = _xrange[1] - 0.5*(_xrange[1] - _xrange[0]) return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='gray',weight='bold', - fontsize=20,alpha=0.6,horizontalalignment='center') + fontsize=_size,alpha=0.6,horizontalalignment='center') elif _loc=='lower left': _yrange = _axis.get_ylim() _use_y = _yrange[0] + 0.1*(_yrange[1] - _yrange[0]) _xrange = _axis.get_xlim() _use_x = _xrange[0] + 0.05*(_xrange[1] - _xrange[0]) return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='gray',weight='bold', - fontsize=20,alpha=0.6) + fontsize=_size,alpha=0.6) elif _loc=='lower right': _yrange = _axis.get_ylim() _use_y = _yrange[0] + 0.1*(_yrange[1] - _yrange[0]) _xrange = _axis.get_xlim() _use_x = _xrange[1] - 0.05*(_xrange[1] - _xrange[0]) return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='gray',weight='bold', - fontsize=20,alpha=0.6,horizontalalignment='right') + fontsize=_size,alpha=0.6,horizontalalignment='right') else: _yrange = _axis.get_ylim() _use_y = _yrange[0] + 0.1*(_yrange[1] - _yrange[0]) _xrange = _axis.get_xlim() _use_x = _xrange[1] - 0.5*(_xrange[1] - _xrange[0]) return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='white',weight='bold', - fontsize=20,alpha=0.6,horizontalalignment='center') + fontsize=_size,alpha=0.6,horizontalalignment='center') -def Preliminary(_axis,_loc='upper left'): +def Preliminary(_axis,_loc='upper left',_size=20): if _loc!='upper left' and _loc!='upper right' and _loc!='upper middle' and _loc!='lower middle' and _loc!='lower left' and _loc!='lower right': print('Invalid location for PRELMINARY tag given. Choose upper left, upper right, upper middle, or lower middle.') elif _loc=='upper left': @@ -153,42 +153,42 @@ def Preliminary(_axis,_loc='upper left'): _xrange = _axis.get_xlim() _use_x = _xrange[0] + 0.05*(_xrange[1] - _xrange[0]) return _axis.text(s='PRELIMINARY',x=_use_x,y=_use_y,color='gray',weight='bold', - fontsize=20,alpha=0.6,rotation=40.) + fontsize=_size,alpha=0.6,rotation=40.) elif _loc=='upper right': _yrange = _axis.get_ylim() _use_y = _yrange[1] - 0.5*(_yrange[1] - _yrange[0]) _xrange = _axis.get_xlim() _use_x = _xrange[1] - 0.05*(_xrange[1] - _xrange[0]) return _axis.text(s='PRELIMINARY',x=_use_x,y=_use_y,color='gray',weight='bold', - fontsize=20,alpha=0.6,rotation=-40.,horizontalalignment='right') + fontsize=_size,alpha=0.6,rotation=-40.,horizontalalignment='right') elif _loc=='upper middle': _yrange = _axis.get_ylim() _use_y = _yrange[1] - 0.1*(_yrange[1] - _yrange[0]) _xrange = _axis.get_xlim() _use_x = _xrange[1] - 0.5*(_xrange[1] - _xrange[0]) return _axis.text(s='PRELIMINARY',x=_use_x,y=_use_y,color='gray',weight='bold', - fontsize=20,alpha=0.6,horizontalalignment='center') + fontsize=_size,alpha=0.6,horizontalalignment='center') elif _loc=='lower left': _yrange = _axis.get_ylim() _use_y = _yrange[1] - 0.1*(_yrange[1] - _yrange[0]) _xrange = _axis.get_xlim() _use_x = _xrange[0] + 0.05*(_xrange[1] - _xrange[0]) return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='gray',weight='bold', - fontsize=20,alpha=0.6) + fontsize=_size,alpha=0.6) elif _loc=='lower right': _yrange = _axis.get_ylim() _use_y = _yrange[1] - 0.1*(_yrange[1] - _yrange[0]) _xrange = _axis.get_xlim() _use_x = _xrange[1] - 0.05*(_xrange[1] - _xrange[0]) return _axis.text(s='WORK IN PROGRESS',x=_use_x,y=_use_y,color='gray',weight='bold', - fontsize=20,alpha=0.6,horizontalalignment='right') + fontsize=_size,alpha=0.6,horizontalalignment='right') else: _yrange = _axis.get_ylim() _use_y = _yrange[0] + 0.1*(_yrange[1] - _yrange[0]) _xrange = _axis.get_xlim() _use_x = _xrange[1] - 0.5*(_xrange[1] - _xrange[0]) return _axis.text(s='PRELIMINARY',x=_use_x,y=_use_y,color='white',weight='bold', - fontsize=20,alpha=0.6,horizontalalignment='center') + fontsize=_size,alpha=0.6,horizontalalignment='center') ####################### ## Ratio canvas