# coding=utf-8
import logging
import traceback
from os import makedirs
from os.path import exists, join
from textwrap import fill

import matplotlib.patheffects as PathEffects
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from koino.plot import big_square, default_alpha
from matplotlib import cm

from ..utils.base import jaccard


def plot_silhouette(
    X, figure_fp, n_clusters, silhouette_values, cluster_labels, silhouette_avg
):
    # Create a subplot with 1 row and 2 columns
    fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(26, 10))

    # The 1st subplot is the silhouette plot
    # The silhouette coefficient can range from -1, 1 but here  all
    # lie within [-0.1, 1]
    ax1.set_xlim([-0.1, 1])
    # The (n_clusters+1)*10 is for inserting blank space between silhouette
    # plots of individual clusters, to demarcate them clearly.
    ax1.set_ylim([0, len(X) + (n_clusters + 1) * 10])

    y_lower = 10
    for k in range(n_clusters):
        # Aggregate the silhouette scores for samples belonging to
        # cluster i, and sort them
        ith_cluster_silhouette_values = np.sort(silhouette_values[cluster_labels == k])

        size_cluster_i = ith_cluster_silhouette_values.shape[0]
        y_upper = y_lower + size_cluster_i

        color = cm.spectral(float(k) / n_clusters)
        ax1.fill_betweenx(
            
np.arange(y_lower, y_upper)