File size: 1,002 Bytes
bd39f54
8d94a86
bd39f54
 
10c7c36
086c1e6
10c7c36
bd39f54
 
10c7c36
 
bd39f54
 
10c7c36
 
bd39f54
 
 
 
10c7c36
bd39f54
 
 
 
 
 
 
 
 
 
10c7c36
 
 
 
 
 
bd39f54
10c7c36
bd39f54
10c7c36
bd39f54
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import matplotlib.pyplot as plt
import numpy as np


def draw_histogram(nums, labels, paint_object, will_rotate=False, will_show_text=True):
    plt.clf()
    plt.figure(figsize=(10, 8), dpi=300)

    bars = plt.bar(
        np.arange(0, len(nums)),
        nums,
        align="center",
        alpha=1,
        color=paint_object.get_color_cur_list()[0],
        tick_label=labels
    )

    if will_show_text:
        for bar in bars:
            plt.annotate(
                str(bar.get_height()),
                xy=(bar.get_x() + bar.get_width() / 2,
                    bar.get_height()),
                xytext=(0, 3),
                textcoords="offset points",
                va="bottom",
                ha="center"
            )

    if will_rotate:
        plt.xticks(rotation=-45)

    plt.title(paint_object.get_name())

    plt.xlabel(paint_object.get_x_cur_label())
    plt.ylabel(paint_object.get_y_cur_label())

    paint_object.set_color_cur_num(1)

    return plt, paint_object