Python matplotlib.pyplot.stackplot() Examples

The following are code examples for showing how to use matplotlib.pyplot.stackplot(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: Blackjack-Tracker   Author: martinabeleda   File: test_axes.py    MIT License 6 votes vote down vote up
def test_stackplot():
    fig = plt.figure()
    x = np.linspace(0, 10, 10)
    y1 = 1.0 * x
    y2 = 2.0 * x + 1
    y3 = 3.0 * x + 2
    ax = fig.add_subplot(1, 1, 1)
    ax.stackplot(x, y1, y2, y3)
    ax.set_xlim((0, 10))
    ax.set_ylim((0, 70))

    # Reuse testcase from above for a labeled data test
    data = {"x": x, "y1": y1, "y2": y2, "y3": y3}
    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1)
    ax.stackplot("x", "y1", "y2", "y3", data=data)
    ax.set_xlim((0, 10))
    ax.set_ylim((0, 70)) 
Example 2
Project: hermes-simulation   Author: xfontes42   File: data_plotting.py    MIT License 6 votes vote down vote up
def plot_accumulated_actor_graph(actors_flow_acc: List[List[float]], n_runs):
    """Plot the road network occupation during the simulation"""
    # Your x and y axis
    data = np.array(actors_flow_acc)
    x, y, z = data[:, 0], data[:, 1], data[:, 2]
    y = [y/n_runs, z/n_runs]

    # use a known color palette (see..)
    pal = sns.color_palette("Set1")
    plt.stackplot(x, y, labels=['with atis', 'without atis'],
                  colors=pal, alpha=0.4)
    plt.xlabel("hours")
    plt.ylabel("actors in graph")
    plt.legend(loc='upper right')
    plt.xlim(right=30)
    plt.show() 
Example 3
Project: HSRL   Author: fuguoji   File: lp.py    MIT License 6 votes vote down vote up
def cal_auc(y_test, y_score):
    """
    calculate AUC value and plot the ROC curve
    """
    fpr, tpr, threshold = roc_curve(y_test, y_score)
    roc_auc = auc(fpr, tpr)
    # plt.figure()
    # plt.stackplot(fpr, tpr, color='steelblue', alpha = 0.5, edgecolor = 'black')
    # plt.plot(fpr, tpr, color='black', lw = 1)
    # plt.plot([0,1],[0,1], color = 'red', linestyle = '--')
    # plt.text(0.5,0.3,'ROC curve (area = %0.3f)' % roc_auc)
    # plt.xlabel('False Positive Rate')
    # plt.ylabel('True Positive Rate')
    # plt.show()

    return roc_auc 
Example 4
Project: Process-Drift-Visualization-With-Declare   Author: yesanton   File: visualize_drift_plot.py    MIT License 6 votes vote down vote up
def drawDriftPlotforAllClusters(ts = None, clusters_dict=None, cluster_order = None):
    lines_for_lineplot = []
    for key in cluster_order:
        averaged_line = [0] * (len(clusters_dict[key][0]) - 3)
        for i in range(len(clusters_dict[key])):
            for j in range(len(averaged_line)):
                averaged_line[j] += clusters_dict[key][i][j + 3]
        lines_for_lineplot.append(averaged_line)

    # Data
    x = range(0, len(lines_for_lineplot[0]))
    plt.clf()
    # Plot
    plt.stackplot(x, lines_for_lineplot)
    plt.xticks(x, ts, rotation='vertical')
    plt.legend(loc='upper left')
    plt.show() 
Example 5
Project: ble5-nrf52-mac   Author: tomasero   File: test_pyplot.py    MIT License 5 votes vote down vote up
def test_stackplot_smoke():
    # Small smoke test for stackplot (see #12405)
    plt.stackplot([1, 2, 3], [1, 2, 3]) 
Example 6
Project: neural-network-animation   Author: miloharper   File: test_axes.py    MIT License 5 votes vote down vote up
def test_stackplot():
    fig = plt.figure()
    x = np.linspace(0, 10, 10)
    y1 = 1.0 * x
    y2 = 2.0 * x + 1
    y3 = 3.0 * x + 2
    ax = fig.add_subplot(1, 1, 1)
    ax.stackplot(x, y1, y2, y3)
    ax.set_xlim((0, 10))
    ax.set_ylim((0, 70)) 
Example 7
Project: neural-network-animation   Author: miloharper   File: test_axes.py    MIT License 5 votes vote down vote up
def test_stackplot_baseline():
    np.random.seed(0)

    def layers(n, m):
        def bump(a):
            x = 1 / (.1 + np.random.random())
            y = 2 * np.random.random() - .5
            z = 10 / (.1 + np.random.random())
            for i in range(m):
                w = (i / float(m) - y) * z
                a[i] += x * np.exp(-w * w)
        a = np.zeros((m, n))
        for i in range(n):
            for j in range(5):
                bump(a[:, i])
        return a

    d = layers(3, 100)

    fig = plt.figure()

    plt.subplot(2, 2, 1)
    plt.stackplot(list(xrange(100)), d.T, baseline='zero')

    plt.subplot(2, 2, 2)
    plt.stackplot(list(xrange(100)), d.T, baseline='sym')

    plt.subplot(2, 2, 3)
    plt.stackplot(list(xrange(100)), d.T, baseline='wiggle')

    plt.subplot(2, 2, 4)
    plt.stackplot(list(xrange(100)), d.T, baseline='weighted_wiggle') 
Example 8
Project: python3_ios   Author: holzschu   File: test_pyplot.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_stackplot_smoke():
    # Small smoke test for stackplot (see #12405)
    plt.stackplot([1, 2, 3], [1, 2, 3]) 
Example 9
Project: linear_neuron   Author: uglyboxer   File: test_axes.py    MIT License 5 votes vote down vote up
def test_stackplot():
    fig = plt.figure()
    x = np.linspace(0, 10, 10)
    y1 = 1.0 * x
    y2 = 2.0 * x + 1
    y3 = 3.0 * x + 2
    ax = fig.add_subplot(1, 1, 1)
    ax.stackplot(x, y1, y2, y3)
    ax.set_xlim((0, 10))
    ax.set_ylim((0, 70)) 
Example 10
Project: linear_neuron   Author: uglyboxer   File: test_axes.py    MIT License 5 votes vote down vote up
def test_stackplot_baseline():
    np.random.seed(0)

    def layers(n, m):
        def bump(a):
            x = 1 / (.1 + np.random.random())
            y = 2 * np.random.random() - .5
            z = 10 / (.1 + np.random.random())
            for i in range(m):
                w = (i / float(m) - y) * z
                a[i] += x * np.exp(-w * w)
        a = np.zeros((m, n))
        for i in range(n):
            for j in range(5):
                bump(a[:, i])
        return a

    d = layers(3, 100)

    fig = plt.figure()

    plt.subplot(2, 2, 1)
    plt.stackplot(list(xrange(100)), d.T, baseline='zero')

    plt.subplot(2, 2, 2)
    plt.stackplot(list(xrange(100)), d.T, baseline='sym')

    plt.subplot(2, 2, 3)
    plt.stackplot(list(xrange(100)), d.T, baseline='wiggle')

    plt.subplot(2, 2, 4)
    plt.stackplot(list(xrange(100)), d.T, baseline='weighted_wiggle') 
Example 11
Project: psychrometric-chart-makeover   Author: buds-lab   File: test_pyplot.py    MIT License 5 votes vote down vote up
def test_stackplot_smoke():
    # Small smoke test for stackplot (see #12405)
    plt.stackplot([1, 2, 3], [1, 2, 3]) 
Example 12
Project: scvelo   Author: theislab   File: utils.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def fraction_timeseries(adata, xkey='clusters', tkey='dpt_pseudotime', bins=30, legend_loc='best', title=None,
                        fontsize=None, ax=None, figsize=None, dpi=None, xlabel=None, ylabel=None, show=True):
    t = np.linspace(0, 1 + 1 / bins, bins)
    types = np.unique(adata.obs[xkey].values)

    y = []
    for i in range(bins - 1):
        mask = np.all([adata.obs[tkey].values <= t[i + 1], adata.obs[tkey].values > t[i]], axis=0)
        x = list(adata[mask].obs[xkey].values)
        y.append([])
        for name in types:
            occur = x.count(name)
            y[-1].append(occur)
        y[-1] /= np.sum(y[-1])
    y = np.array(y).T

    ax = pl.figure(figsize=figsize, dpi=dpi) if ax is None else ax

    pl.stackplot(t[:-1], y, baseline='zero', labels=types,
                 colors=adata.uns['clusters_colors'] if 'clusters_colors' in adata.uns.keys() else None,
                 edgecolor='white')

    pl.legend(types, loc=legend_loc)
    if title is not None:
        pl.title(title, fontsize=fontsize)
    pl.xlabel(tkey if xlabel is None else xlabel, fontsize=fontsize)
    pl.ylabel(xkey + ' fractions' if ylabel is None else ylabel, fontsize=fontsize)
    pl.xlim(adata.obs[tkey].values.min(), adata.obs[tkey].values.max())
    pl.ylim(0, 1)

    if not show:
        return ax
    else:
        pl.show() 
Example 13
Project: git-of-theseus   Author: erikbern   File: stack_plot.py    Apache License 2.0 5 votes vote down vote up
def stack_plot(input_fn, display=False, outfile='stack_plot.png', max_n=20, normalize=False, dont_stack=False):
    data = json.load(open(input_fn))  # TODO do we support multiple arguments here?
    y = numpy.array(data['y'])
    if y.shape[0] > max_n:
        js = sorted(range(len(data['labels'])), key=lambda j: max(y[j]), reverse=True)
        other_sum = numpy.sum(y[j] for j in js[max_n:])
        top_js = sorted(js[:max_n], key=lambda j: data['labels'][j])
        y = numpy.array([y[j] for j in top_js] + [other_sum])
        labels = [data['labels'][j] for j in top_js] + ['other']
    else:
        labels = data['labels']
    if normalize:
        y = 100. * numpy.array(y) / numpy.sum(y, axis=0)
    pyplot.figure(figsize=(13, 8))
    pyplot.style.use('ggplot')
    ts = [dateutil.parser.parse(t) for t in data['ts']]
    colors = generate_n_colors(len(labels))
    if dont_stack:
        for color, label, series in zip(colors, labels, y):
            pyplot.plot(ts, series, color=color, label=label, linewidth=2)
    else:
        pyplot.stackplot(ts, numpy.array(y), labels=labels, colors=colors)
    pyplot.legend(loc=2)
    if normalize:
        pyplot.ylabel('Share of lines of code (%)')
        pyplot.ylim([0, 100])
    else:
        pyplot.ylabel('Lines of code')
    print('Writing output to %s' % outfile)
    pyplot.savefig(outfile)
    pyplot.tight_layout()
    if display:
        pyplot.show() 
Example 14
Project: SignLanguage_ML   Author: mareep-raljodid   File: test_pyplot.py    MIT License 5 votes vote down vote up
def test_stackplot_smoke():
    # Small smoke test for stackplot (see #12405)
    plt.stackplot([1, 2, 3], [1, 2, 3]) 
Example 15
Project: asg-sim   Author: bellkev   File: utils.py    MIT License 5 votes vote down vote up
def make_scaling_plot(params, title, path, axis=None):
    m = run_model(**params)
    purple = '#BBA4D1'
    blue = '#3399CC'
    plt_title(title)
    plt.stackplot([(tick * params['sec_per_tick']) / 60.0 for tick in range(m.ticks)], m.builders_in_use, m.builders_available,
                  colors=(purple, blue), linewidth=0)
    plt.legend([mpatches.Patch(color=purple),
                mpatches.Patch(color=blue)],
               ['Busy Builder Machines','Available Builder Machines'])
    plt.xlabel('Time (m)')
    plt.ylabel('Machines')
    if axis:
        plt.axis(axis)
    plt_save(path) 
Example 16
Project: ImageFusion   Author: pfchai   File: test_axes.py    MIT License 5 votes vote down vote up
def test_stackplot():
    fig = plt.figure()
    x = np.linspace(0, 10, 10)
    y1 = 1.0 * x
    y2 = 2.0 * x + 1
    y3 = 3.0 * x + 2
    ax = fig.add_subplot(1, 1, 1)
    ax.stackplot(x, y1, y2, y3)
    ax.set_xlim((0, 10))
    ax.set_ylim((0, 70)) 
Example 17
Project: ImageFusion   Author: pfchai   File: test_axes.py    MIT License 5 votes vote down vote up
def test_stackplot_baseline():
    np.random.seed(0)

    def layers(n, m):
        def bump(a):
            x = 1 / (.1 + np.random.random())
            y = 2 * np.random.random() - .5
            z = 10 / (.1 + np.random.random())
            for i in range(m):
                w = (i / float(m) - y) * z
                a[i] += x * np.exp(-w * w)
        a = np.zeros((m, n))
        for i in range(n):
            for j in range(5):
                bump(a[:, i])
        return a

    d = layers(3, 100)

    fig = plt.figure()

    plt.subplot(2, 2, 1)
    plt.stackplot(list(xrange(100)), d.T, baseline='zero')

    plt.subplot(2, 2, 2)
    plt.stackplot(list(xrange(100)), d.T, baseline='sym')

    plt.subplot(2, 2, 3)
    plt.stackplot(list(xrange(100)), d.T, baseline='wiggle')

    plt.subplot(2, 2, 4)
    plt.stackplot(list(xrange(100)), d.T, baseline='weighted_wiggle') 
Example 18
Project: Blackjack-Tracker   Author: martinabeleda   File: test_axes.py    MIT License 5 votes vote down vote up
def test_stackplot_baseline():
    np.random.seed(0)

    def layers(n, m):
        def bump(a):
            x = 1 / (.1 + np.random.random())
            y = 2 * np.random.random() - .5
            z = 10 / (.1 + np.random.random())
            a += x * np.exp(-((np.arange(m) / m - y) * z) ** 2)
        a = np.zeros((m, n))
        for i in range(n):
            for j in range(5):
                bump(a[:, i])
        return a

    d = layers(3, 100)
    d[50, :] = 0  # test for fixed weighted wiggle (issue #6313)

    fig = plt.figure()

    plt.subplot(2, 2, 1)
    plt.stackplot(list(xrange(100)), d.T, baseline='zero')

    plt.subplot(2, 2, 2)
    plt.stackplot(list(xrange(100)), d.T, baseline='sym')

    plt.subplot(2, 2, 3)
    plt.stackplot(list(xrange(100)), d.T, baseline='wiggle')

    plt.subplot(2, 2, 4)
    plt.stackplot(list(xrange(100)), d.T, baseline='weighted_wiggle') 
Example 19
Project: hermes-simulation   Author: xfontes42   File: data_plotting.py    MIT License 5 votes vote down vote up
def plot_accumulated_edges_graphs(edges_accumulated: Dict[str, List[List[float]]], n_runs):
    """Plot the actors occupation of all edges during the simulation"""
    fig = plt.figure()
    n_edges = len(edges_accumulated.keys())
    edge_list = sorted(list(edges_accumulated.keys()))
    for i, e_key in enumerate(edge_list):
        edge_data = edges_accumulated[e_key]
        edge_data = np.array(edge_data)
        x, y, z = edge_data[:, 0], edge_data[:, 1], edge_data[:, 2]
        y = [y / n_runs, z / n_runs]

        ax = fig.add_subplot(
            4,
            int((n_edges / 4 + 0.5)),
            i + 1
        )
        ax.text(.2, .9, str(e_key),
                horizontalalignment='right',
                transform=ax.transAxes)

        pal = sns.color_palette("Set1")
        ax.stackplot(x, y, labels=['atis', 'natis'], colors=pal, alpha=0.4)
        ax.legend(loc='upper right')
        plt.xlim(right=28)

    plt.show() 
Example 20
Project: lambda-tensorflow-object-detection   Author: mikylucky   File: test_pyplot.py    GNU General Public License v3.0 5 votes vote down vote up
def test_stackplot_smoke():
    # Small smoke test for stackplot (see #12405)
    plt.stackplot([1, 2, 3], [1, 2, 3]) 
Example 21
Project: taobao_crawler   Author: rwv   File: sold_number_analyzer.py    MIT License 5 votes vote down vote up
def __draw_stack_chart(self, div):
        """
        画堆栈图

        :param div: 划分区间数
        :return: 一个 matplotlib.pyplot 实例
        """
        prices_list = []
        for i in self.__sold.values():
            for j in i.keys():
                prices_list.append(j)
        min_price = int(floor(min(prices_list)))
        max_price = int(ceil(max(prices_list)))

        # generate the price sequence from max price and min price
        prices_seq = list(range(min_price, max_price, int((max_price - min_price) / div)))
        if prices_seq[-1] != max_price:
            prices_seq.append(max_price)

        # generate the related sold list
        temp = prices_seq.copy()
        temp.append(max_price + 1)
        brands = list(self.keywords.keys())
        counts = []
        for brand in brands:
            temp_list = list()
            for i in range(len(temp) - 1):
                temp_list.append(self.__get_sold(temp[i], temp[i + 1], brand))
            counts.append(temp_list)

        plt.figure(figsize=(15, 5))
        plt.style.use('ggplot')
        plt.stackplot(prices_seq, counts, labels=brands)
        plt.legend(loc='best')
        plt.tick_params(top='off', right='off')
        return plt 
Example 22
Project: Process-Drift-Visualization-With-Declare   Author: yesanton   File: visualize_drift_plot.py    MIT License 5 votes vote down vote up
def draw_drift_plot_for_one_cluster(ts=None,
                                    clusters_dict=None,
                                    key=None,
                                    vertical=None,
                                    file_ind = None,
                                    fileMngm=None):
    averaged_line = [0] * (len(clusters_dict[key][0]) - 3)

    for i in range(len(clusters_dict[key])):
        for j in range(len(averaged_line)):
            averaged_line[j] += clusters_dict[key][i][j + 3]

    for j in range(len(averaged_line)):
        averaged_line[j] /= len(clusters_dict[key]) * 100

    xnew = range(0, len(averaged_line))
    spl = make_interp_spline(range(len(averaged_line)), averaged_line, k=2)  # BSpline object
    power_smooth = spl(xnew)
    plt.clf()

    plt.stackplot(xnew, power_smooth)  # , labels=['A', 'B', 'C']
    if vertical:
        if len(vertical) > 1:
            vert = vertical[key]
        else:
            vert = vertical[0]
        vert = vert[:-1]
        for line in vert:
            plt.axvline(x=line, color='black', dashes=(2, 2))
    plt.xticks(xnew, ts, rotation='vertical')
    plt.ylim(top=1)

    # export the image
    plt.savefig(fileMngm.get_path_drift_plot(file_ind), bbox_inches='tight')
    return power_smooth, xnew, averaged_line

# This function draws Drift plots for each cluster and returns the Erratic measure of that cluster 
Example 23
Project: faas-profiler   Author: PrincetonUniversity   File: TestDataframePlotting.py    MIT License 4 votes vote down vote up
def PerfMonPlotter(perf_mon_records, time_window = None):
    """
    For plotting performance monitoring records.
    """
    # Entire records
    pqos_records = perf_mon_records['pqos_records']
    # perf_records = perf_mon_records['perf_records']
    # # Select a time window if provided
    # if time_window is not None:
    #     test_start = pqos_records['timestamp'].min()
    #     time_window = [5, 10]
    #     selection_bounds = [test_start + timedelta(seconds=time_window[0]), \
    #                         test_start + timedelta(seconds=time_window[1])]
    #     pqos_records['In Test Bound'] = (pqos_records['timestamp']>selection_bounds[0]) \
    #                                     & (pqos_records['timestamp']<selection_bounds[1])
    #     perf_records['In Test Bound'] = (perf_records['timestamp']>time_window[0]) \
    #                                     & (perf_records['timestamp']<time_window[1])
    #     pqos_df = pqos_records[pqos_records['In Test Bound']==True]
    #     perf_df = perf_records[perf_records['In Test Bound']==True]

    palette = sns.color_palette("rocket_r", 16)
    
    # 'timestamp','Core','IPC','LLC Misses','LLC Util (KB)','MBL (MB/s)'
    fig, axs = plt.subplots(ncols=2, nrows=2, sharex=True)
    pqos_records_sum = pqos_records.groupby('timestamp').sum()
    pqos_records_sum.plot(y='IPC', ax=axs[0][0])
    pqos_records_sum.plot(y='MBL (MB/s)', ax=axs[0][1])
    pqos_records_sum.plot(y='LLC Util (KB)', ax=axs[1][0])
    pqos_records_sum.plot(y='LLC Misses', ax=axs[1][1])
    axs[0][0].set_ylim([0,20])

    # sns.relplot(data=pqos_records, x='timestamp', y='IPC', hue='Core', kind='line', palette=palette, alpha=0.75)
    # sns.relplot(data=pqos_records, x='timestamp', y='MBL (MB/s)', hue='Core', kind='scatter', palette=palette, alpha=0.75)
    # sns.lmplot(data=pqos_df.groupby('timestamp').sum(), x='IPC', y='MBL (MB/s)', palette=palette,
    #            truncate=True, order=5, fit_reg=False, scatter_kws={'alpha':0.5}, legend_out=False)
    # sns.jointplot(data=pqos_df.groupby('timestamp').sum(), x='LLC Util (KB)', y='MBL (MB/s)', kind="hex", zorder=0)
                #  .plot_joint(sns.kdeplot, zorder=10, n_levels=25, bw='silverman')

    # cpu-cycles,L1-dcache-loads,L1-dcache-load-misses,L1-icache-load-misses,dTLB-load-misses,dTLB-loads,
    # iTLB-load-misses,iTLB-loads,branch-misses,context-switches,cpu-migrations,page-faults
    # sns.relplot(data=perf_records, x='timestamp', y='context-switches', kind='line', palette=palette, alpha=0.75)
    # plt.stackplot(perf_records['timestamp'], perf_records['r4f1'], perf_records['r2f1'], perf_records['r1f1'])
    # sns.relplot(data=perf_df, x='context-switches', y='r1f1', kind='scatter', palette=palette, alpha=0.75)
    # perf_records['Branch Miss Rate (%)'] = 100.0*perf_records['branch-misses']/perf_records['branches']
    # sns.lmplot(data=perf_records, x='context-switches', y='block:block_plug',
    #            truncate=True, order=8, scatter_kws={'alpha':0.5}, legend_out=False)
    # sns.jointplot(data=perf_df, x='dTLB-loads', y='iTLB-loads', kind="hex", zorder=0)

    plt.show()
    plt.close()

    return True 
Example 24
Project: message-analyser   Author: vlajnaya-mol   File: plotter.py    MIT License 4 votes vote down vote up
def stackplot_non_text_messages_percentage(msgs, path_to_save):
    sns.set(style="whitegrid", palette="muted")

    colors = ['y', 'b', 'c', 'r', 'g', 'm']

    (x, y_total), (xticks, xticks_labels, xlabel) = _get_plot_data(msgs), _get_xticks(msgs)

    stacks = stools.get_non_text_messages_grouped(y_total)

    # Normalize values
    for i in range(len(stacks[0]["groups"])):
        total = sum(stack["groups"][i] for stack in stacks)
        for stack in stacks:
            if not total:
                stack["groups"][i] = 0
            else:
                stack["groups"][i] /= total

    plt.stackplot(x, *[stack["groups"] for stack in stacks], labels=[stack["type"] for stack in stacks],
                  colors=colors, alpha=0.7)

    plt.margins(0, 0)
    plt.xticks(xticks, rotation=65)
    plt.yticks([i / 10 for i in range(0, 11, 2)])

    ax = plt.gca()
    ax.set_xticklabels(xticks_labels)
    ax.set_yticklabels([f"{i}%" for i in range(0, 101, 20)])
    ax.tick_params(axis='x', bottom=True, color="#A9A9A9")
    ax.set(xlabel=xlabel, ylabel="non-text messages")

    # https://stackoverflow.com/a/4701285
    # Shrink current axis by 10%
    box = ax.get_position()
    ax.set_position([box.x0, box.y0, box.width * 0.9, box.height])
    # Put a legend to the right of the current axis
    ax.legend(loc="center left", bbox_to_anchor=(1, 0.5))

    fig = plt.gcf()
    fig.set_size_inches(11, 8)

    fig.savefig(os.path.join(path_to_save, stackplot_non_text_messages_percentage.__name__ + ".png"), dpi=500)
    # plt.show()
    log_line(f"{stackplot_non_text_messages_percentage.__name__} was created.")
    plt.close("all") 
Example 25
Project: taobao_crawler   Author: rwv   File: size_info_analyzer_with_time.py    MIT License 4 votes vote down vote up
def __draw_stack_chart(self, brand):
        # handle the data
        data = self.__rates_count[brand]
        years_weeks = list()
        for key, values in data.items():
            for value in values.keys():
                years_weeks.append(isoweek.Week(key, value))
        years_weeks = sorted(years_weeks)  # a year have 53 weeks at most
        count_by_time = dict()
        for classifier in self.classifiers:
            temp = list()
            count_by_time[classifier] = temp
        for year_week in years_weeks:
            for classifier in self.classifiers:
                count_by_time[classifier].append(self.__get_value(brand, classifier, year_week.year, year_week.week))

        # draw the pic
        axis_label = years_weeks.copy()
        min_week = isoweek.Week(min(years_weeks).year, 0)
        years_weeks = list(map(lambda x: x - min_week, years_weeks))
        count = list()
        labels = list()
        for k, v in count_by_time.items():
            count.append(v)
            labels.append(k)

        axis_label = list(map(lambda x: x.week, axis_label))

        # convert the sum of sold number to 1
        for j in range(len(count[0])):
            s = 0
            for i in range(len(count)):
                s += count[i][j]
            for i in range(len(count)):
                count[i][j] /= s

        plt.figure(figsize=(15, 5))
        plt.style.use('ggplot')
        plt.stackplot(years_weeks, count, labels=labels)
        plt.legend(loc='best')
        plt.tick_params(top='off', right='off')
        plt.xticks(years_weeks[::int(len(axis_label) / 15)], axis_label[::int(len(axis_label) / 15)])