import matplotlib.pyplot as plt
from matplotlib.patches import Patch
import numpy as np
from scipy.interpolate import make_interp_spline
# 1. OATP1B3 Inhibitor Facts
bin_centers = [0.25, 0.30, 0.35, 0.40, 0.45, 0.50, 0.55, 0.60,
0.65, 0.70, 0.75, 0.80, 0.85, 0.90, 0.95, 1.0]
frequencies = [0.04, 0.20, 0.65, 0.85, 0.77, 1.09, 1.09, 1.54,
1.74, 2.39, 2.83, 4.25, 7.77, 11.17, 24.56, 39.08]
# 2. Smoothing (Spline for exponential trend)
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 (Interaction Intensity)
colors = []
for val in bin_centers:
if val < 0.6:
colors.append('lightgray')
elif val < 0.85:
colors.append('coral')
else:
colors.append('darkred')
# 4. Create the chart
plt.figure(figsize=(7, 6))
# Bars
plt.bar(bin_centers, frequencies, width=0.04, color=colors, edgecolor='black', alpha=0.85, label='Data Frequency')
# 5. Tags and Titles
plt.xlabel('Probability of OATP1B3 Inhibition', fontsize=12)
plt.ylabel('% Frequency', fontsize=12)
plt.title('OATP1B3 Inhibition Potential (Dominant Hepatic Uptake)', fontsize=14)
# Axle settings
plt.xticks(np.arange(0.2, 1.05, 0.1))
plt.xlim(0.2, 1.05)
plt.ylim(0, 42)
# 6. Legend
legend_elements = [
Patch(facecolor='lightgray', edgecolor='black', label='Low Potential (< 0.6)'),
Patch(facecolor='coral', edgecolor='black', label='Moderate Potential (0.6 - 0.85)'),
Patch(facecolor='darkred', edgecolor='black', label='High Potential (> 0.85)'),
]
plt.legend(handles=legend_elements, loc='upper left', framealpha=0.95)
plt.grid(axis='y', linestyle='--', alpha=0.5)
plt.tight_layout()
plt.show()