import matplotlib.pyplot as plt
from matplotlib.patches import Patch
from matplotlib.lines import Line2D
import numpy as np
# 1. VDss data (Log L/kg)
bin_centers = [-1.2, -1.0, -0.8, -0.6, -0.4, -0.2, 0.0,
0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6]
frequencies = [0.20, 1.33, 6.88, 10.23, 11.17, 14.12, 14.85,
13.96, 10.07, 7.16, 4.05, 3.20, 1.78, 0.77, 0.24]
# 2. Gaussian Fit Parameters (Provided)
amplitude = 14.90
mean = -0.04540
sd = 0.5412
# Generate smooth curve
x_smooth = np.linspace(min(bin_centers), max(bin_centers), 300)
y_smooth = amplitude * np.exp(-0.5 * ((x_smooth - mean) / sd)**2)
# 3. Define colors (VDss Classification)
colors = []
for val in bin_centers:
# High VDss (> 0.5 Log) -> Tissues
if val > 0.5:
colors.append('royalblue')
# Low VDss (< -0.6 Log) -> Plasma
elif val < -0.6:
colors.append('firebrick')
# Medium VDss -> Body Water
else:
colors.append('gold')
# 4. Create the chart
plt.figure(figsize=(7, 6))
# A. Bars
plt.bar(bin_centers, frequencies, width=0.15, color=colors, edgecolor='black', alpha=0.7, label='Data Frequency')
# B. Gaussian curve
plt.plot(x_smooth, y_smooth, color='darkorange', linewidth=2, label='Gaussian Fit')
# 5. Tags and Titles
plt.xlabel('VDss (Steady State Volume of Distribution) [Log L/kg]', fontsize=12)
plt.ylabel('% Frequency', fontsize=12)
plt.title('VDss Distribution', fontsize=14)
# Axle settings
plt.xticks(np.arange(-1.2, 1.8, 0.2))
plt.xlim(-1.4, 1.8)
plt.ylim(0, 16)
# 6. Legend
legend_elements = [
Line2D([0], [0], color='darkorange', lw=2.5, label=f'Fit (Mean={mean}, SD={sd})'),
Patch(facecolor='firebrick', edgecolor='black', alpha=0.7, label='Low VDss (Plasma Restricted)'),
Patch(facecolor='gold', edgecolor='black', alpha=0.7, label='Medium VDss (Body Water)'),
Patch(facecolor='royalblue', edgecolor='black', alpha=0.7, label='High VDss (Tissue Accumulation)'),
]
plt.legend(handles=legend_elements, loc='upper right', framealpha=0.9)
plt.grid(axis='y', linestyle='--', alpha=0.5)
plt.tight_layout()
plt.show()