<｜begin▁of▁sentence｜>### Instruction:
Given a color specified by an RGB triplet (e.g., '#6699CC'), how would you use a Python function to create a darker version of this color by mixing it with black with a specified ratio (e.g., 0.5)?
### Response:
from matplotlib.colors import to_rgb

# Function to darken a color given by an RGB triplet
def darken(color, ratio):
    r, g, b = to_rgb(color)
    r_new, g_new, b_new = r * (1 - ratio), g * (1 - ratio), b * (1 - ratio)
    return (r_new, g_new, b_new)

# Example usage
darkened_color = darken('#6699CC', 0.5)
print(f'Original color: #6699CC\nDarkened color: {darkened_color}')
<|EOT|>
