Example #1
0
def plotrects(*rects, plot_options=None, random_color=None, area_w=DEFAULT_AREA_W, area_h=DEFAULT_AREA_H, jitter=True):
    def get_jitter():
        if jitter:
            return random.random() * JITTER_SIZE
        else:
            return 0

    if plot_options is None:
        if random_color:
            plot_options = [{"fc":get_quali_color(), "alpha":DEFAULT_ALPHA} if c else {"fc":"white", "ec":"black", "lw":3} for c in random_color]
        else:
            plot_options = [{"fc":get_quali_color(), "alpha":DEFAULT_ALPHA} for _ in rects]

    for rect, plot_option in zip(rects, plot_options):
        x = rect[COOR][0][0]
        y = rect[COOR][1][0]
        w = rect[COOR][0][1] - x
        h = rect[COOR][1][1] - y
        plt.gca().add_patch(plt.Rectangle((x + get_jitter(), y + get_jitter()), w + get_jitter(), h + get_jitter(), **plot_option))

    plt.xlim([0, area_w])
    plt.ylim([0, area_h])
    plt.axes().set_aspect("equal")
    plt.show()
Example #2
0
from helper import CMAP, get_quali_color

print(get_quali_color(1, "colors"))
from helper import CMAP, get_quali_color


print(get_quali_color(1, "colors"))