@@ -775,10 +775,19 @@ def plot_all(data: dict, iso_cls: dict, hyst_cls: dict,
775775 sort_d = np .argsort (des [:, 0 ])[::- 1 ]
776776 ax .plot (des [sort_d , 0 ], des [sort_d , 1 ], "s--" ,
777777 color = C_DES , ms = 4 , lw = 1.4 , label = "Desorption" )
778- pp0_d_s , Va_d_s = des [sort_d , 0 ], des [sort_d , 1 ]
779- pp0_all = np .concatenate ([ads [:, 0 ], pp0_d_s [::- 1 ]])
780- Va_all = np .concatenate ([ads [:, 1 ], Va_d_s [::- 1 ]])
781- ax .fill (pp0_all , Va_all , alpha = 0.10 , color = C_ADS )
778+ # Shade only the hysteresis loop: the p/p0 interval where both branches
779+ # exist, bounded by the two interpolated branches (not a single polygon
780+ # with straight closing edges, which produced a full-width wedge).
781+ p_lo = max (ads [:, 0 ].min (), des [:, 0 ].min ())
782+ p_hi = min (ads [:, 0 ].max (), des [:, 0 ].max ())
783+ if p_hi > p_lo :
784+ p_grid = np .linspace (p_lo , p_hi , 200 )
785+ s_a = np .argsort (ads [:, 0 ])
786+ s_d = np .argsort (des [:, 0 ])
787+ Va_a_g = np .interp (p_grid , ads [s_a , 0 ], ads [s_a , 1 ])
788+ Va_d_g = np .interp (p_grid , des [s_d , 0 ], des [s_d , 1 ])
789+ ax .fill_between (p_grid , Va_a_g , Va_d_g , alpha = 0.10 ,
790+ color = C_ADS , linewidth = 0 )
782791
783792 ax .set_xlabel (r"Relative Pressure ($p/p_0$)" )
784793 ax .set_ylabel (r"Volume Adsorbed (cm$^3$ g$^{-1}$ STP)" )
@@ -791,7 +800,7 @@ def plot_all(data: dict, iso_cls: dict, hyst_cls: dict,
791800 iso_label = iso_cls ["type" ]
792801 hyst_label = hyst_cls ["type" ] if hyst_cls ["type" ] != "None" else ""
793802 ax_ann = iso_label + (f" / { hyst_label } " if hyst_label else "" )
794- ax .text (0.03 , 0.96 , ax_ann , transform = ax .transAxes ,
803+ ax .text (0.03 , 0.78 , ax_ann , transform = ax .transAxes ,
795804 va = "top" , ha = "left" , fontsize = 8.5 ,
796805 bbox = dict (boxstyle = "round,pad=0.3" , fc = "white" ,
797806 ec = "0.7" , lw = 0.7 , alpha = 0.9 ))
@@ -833,6 +842,16 @@ def plot_all(data: dict, iso_cls: dict, hyst_cls: dict,
833842 rp = bjh [:, 0 ] * 2 # radius (nm) -> diameter (nm)
834843 dVdd = bjh [:, 1 ] / 2.0 # dVp/drp -> dVp/ddp
835844
845+ # Upper x-limit from the data: the smallest diameter where the cumulative
846+ # pore volume reaches 99 % of its final value (drops the mostly-empty
847+ # high-diameter tail), with a floor so microporous samples aren't cramped.
848+ x_max = float (rp [- 1 ])
849+ if bjh [- 1 , 2 ] > 0 :
850+ done = np .where (bjh [:, 2 ] >= 0.99 * bjh [- 1 , 2 ])[0 ]
851+ if len (done ):
852+ x_max = float (rp [done [0 ]])
853+ x_max = max (x_max , 5.0 )
854+
836855 ax .plot (rp , dVdd , "-" , color = C_BJH , lw = 1.5 )
837856 ax .fill_between (rp , dVdd , alpha = 0.15 , color = C_BJH )
838857
@@ -843,15 +862,15 @@ def plot_all(data: dict, iso_cls: dict, hyst_cls: dict,
843862
844863 ax .set_xlabel (r"Pore Diameter (nm)" )
845864 ax .set_ylabel (r"d$V_p$/d$d_p$ (cm$^3$ g$^{-1}$ nm$^{-1}$)" )
846- ax .set_xlim (left = 0 )
865+ ax .set_xlim (left = 0 , right = x_max )
847866 ax .set_ylim (bottom = 0 )
848867 ax .xaxis .set_minor_locator (AutoMinorLocator ())
849868 ax .yaxis .set_minor_locator (AutoMinorLocator ())
850869
851870 ax .axvline (N2_CAVITATION_NM , ls = ":" , lw = 0.8 , color = "0.6" , alpha = 0.7 )
852- ax .text (N2_CAVITATION_NM + 0.2 ,
853- ax . get_ylim ()[ 1 ] * 0.01 if ax . get_ylim ()[ 1 ] > 0 else 0.001 ,
854- "cavitation \n (~3.4 nm)" , fontsize = 6.5 , color = "0.5 " , va = "bottom " )
871+ ax .text (N2_CAVITATION_NM , ax . get_ylim ()[ 1 ] * 0.9 ,
872+ "cavitation \n (~3.4 nm)" , fontsize = 6.5 , color = "0.5" ,
873+ va = "top " , ha = "left " )
855874 _label_panel (ax , "C" )
856875
857876 # ── [D] Cumulative Pore Volume ────────────────────────────
@@ -876,7 +895,7 @@ def plot_all(data: dict, iso_cls: dict, hyst_cls: dict,
876895 ax2 .set_ylabel (r"Cum. Surface Area (m$^2$ g$^{-1}$)" , color = C_BJH )
877896 ax .tick_params (axis = "y" , colors = C_CUM )
878897 ax2 .tick_params (axis = "y" , colors = C_BJH )
879- ax .set_xlim (left = 0 )
898+ ax .set_xlim (left = 0 , right = x_max )
880899 ax .set_ylim (bottom = 0 )
881900
882901 lines1 , lbl1 = ax .get_legend_handles_labels ()
0 commit comments