import matplotlib.pyplot as plt
from matplotlib.patches import Patch
import numpy as np
from scipy.interpolate import make_interp_spline
# 1. OATP2B1 Inhibitor Facts
bin_centers = [0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40,
0.45, 0.50, 0.55, 0.60, 0.65, 0.70, 0.75]
frequencies = [18.16, 22.29, 16.34, 10.48, 8.29, 6.23, 5.58, 3.60,
2.99, 2.31, 2.22, 1.09, 0.28, 0.08, 0.04]
# 2. Smoothing (Spline for exponential decay)
x_smooth = np.linspace(min(bin_centers), max(bin_centers), 300)
spl = make_interp_spline(bin_centers, frequencies, k=3)
y_smooth = spl(x_smooth)
y_smooth = [val if val > 0 else 0 for val in y_smooth]
# 3. Colors (Predominant Green = Safe/Non-inhibiting)
colors = []
for val in bin_centers:
if val < 0.3:
colors.append('mediumseagreen')
elif val < 0.5:
colors.append('gold')
else:
colors.append('firebrick')
# 4. Create the chart
plt.figure(figsize=(7, 6))
# Bars
plt.bar(bin_centers, frequencies, width=0.04, color=colors, edgecolor='black', alpha=0.8, label='Data Frequency')
# 5. Tags and Titles
plt.xlabel('Probability of OATP2B1 Inhibition', fontsize=12)
plt.ylabel('% Frequency', fontsize=12)
plt.title('OATP2B1 Inhibition Potential (Intestinal/Hepatic Safety)', fontsize=14)
# Axle settings
plt.xticks(np.arange(0.05, 0.80, 0.05))
plt.xlim(0.0, 0.8)
plt.ylim(0, 25)
# 6. Legend
legend_elements = [
Patch(facecolor='mediumseagreen', edgecolor='black', label='Low Inhibition (Safe for Absorption)'),
Patch(facecolor='gold', edgecolor='black', label='Moderate Potential'),
Patch(facecolor='firebrick', edgecolor='black', label='High Inhibition Potential'),
]
plt.legend(handles=legend_elements, loc='upper right', framealpha=0.95)
plt.grid(axis='y', linestyle='--', alpha=0.5)
plt.tight_layout()
plt.show()