示例#1
0
    def plot_diff_driver(self,
                         x,
                         y,
                         yaw,
                         steer=0.0,
                         robot_length=0.1,
                         wheel_radius=0.05):
        # plot diff driver as a circle
        robot = mpatches.Circle((x, y), robot_length, color='red', zorder=0)
        self.ax.add_patch(robot)
        # plot wheels
        wheel_1 = mpatches.FancyBboxPatch((-robot_length / 2, 0),
                                          wheel_radius / 2,
                                          wheel_radius,
                                          boxstyle=mpatches.BoxStyle("Round",
                                                                     pad=0.01),
                                          color='black',
                                          zorder=0)

        wheel_2 = mpatches.FancyBboxPatch((robot_length / 2, 0),
                                          wheel_radius / 2,
                                          wheel_radius,
                                          boxstyle=mpatches.BoxStyle("Round",
                                                                     pad=0.01),
                                          color='black',
                                          zorder=0)

        t1 = mpl.transforms.Affine2D().rotate_deg(math.degrees(yaw) - 90.0)
        t2 = mpl.transforms.Affine2D().translate(x, y)
        t = t1 + t2 + self.ax.transData
        wheel_1.set_transform(t)
        wheel_2.set_transform(t)

        self.ax.add_patch(wheel_1)
        self.ax.add_patch(wheel_2)
示例#2
0
def plot_ax2_rejected(ax2):
    ax2.set_title('Points per\nrejected-cloud', pad=5, fontsize=SMALL_SIZE + 1)
    ax2.set_xlim(-0.1, 2.1)
    ax2.set_ylim(-0.1, 1.1)
    x_coord = np.linspace(0.0, 2.0, num=nrejected + 1)
    widths = x_coord[1:] - x_coord[:-1]
    patches = []

    for i in range(nrejected):
        x_patch = x_coord[i]
        patches.append(
            mpatches.FancyBboxPatch(
                (x_patch, 0.0),
                widths[i],
                1.0,
                boxstyle=mpatches.BoxStyle("Round", pad=0.0,
                                           rounding_size=0.2)))
        add_label(ax2, (x_patch + 0.5 * widths[i], 0.5),
                  data_size[~ids_bool][i],
                  color='white')
    if nrejected == 0:
        patches.append(
            mpatches.FancyBboxPatch(
                (0.0, 0.0),
                2.0,
                1.0,
                boxstyle=mpatches.BoxStyle("Round", pad=0.0,
                                           rounding_size=0.2)))
        add_label(ax2, (1.0, 0.5), 'None', color='black')

    collection = PatchCollection(patches, alpha=1.0)
    collection.set_edgecolor('k')
    collection.set_facecolor(colors_all[~ids_bool])
    ax2.add_collection(collection)
    ax2.axis('off')
示例#3
0
文件: helpers.py 项目: Fadarrizz/LAD
def Grid(build, variant, amount, totalScore):
    """Places the created houses visually on a grid."""

    # Grid initialization
    fig, ax = plt.subplots()
    plt.axis('scaled')
    plt.xlabel('180 meter')
    plt.ylabel('160 meter')
    ax.grid(which='major', axis='both', color ='silver', linestyle='--')
    intervals = 10
    loc = plticker.MultipleLocator(base=intervals)
    ax.xaxis.set_major_locator(loc)
    ax.yaxis.set_major_locator(loc)
    ax.set_xlim(0, theGrid.xMAX)
    ax.set_ylim(0, theGrid.yMAX)
    ax.set_axisbelow(True)
    plt.suptitle(variant + ' - ' + str(amount) + ' buildings')
    plt.title('score: ${:,.2f}'.format(totalScore))

    # static waterbody placement
    water = Waterbody(20, 104, 40, 36)
    water2 = Waterbody(120, 104, 40, 36)
    water3 = Waterbody(20, 20, 40, 36)
    water4 = Waterbody(120, 20, 40, 36)

    water = patches.Rectangle((water.x, water.y), water.width,
            water.length, facecolor=Waterbody.color, \
            edgecolor = Waterbody.edgecolor)
    ax.add_artist(water)

    water2 = patches.Rectangle((water2.x, water2.y), water2.width,
            water2.length, facecolor=Waterbody.color, \
            edgecolor = Waterbody.edgecolor)
    ax.add_artist(water2)

    water3 = patches.Rectangle((water3.x, water3.y), water3.width,
            water3.length, facecolor=Waterbody.color, \
            edgecolor = Waterbody.edgecolor)
    ax.add_artist(water3)

    water4 = patches.Rectangle((water4.x, water4.y), water4.width,
            water4.length, facecolor=Waterbody.color, \
            edgecolor = Waterbody.edgecolor)
    ax.add_artist(water4)

    # iterate over each house in the build array build and place house on grid
    for i in build:
        meters = i.mtr_clearance

        # temp variable with building information
        temp = patches.Rectangle((i.x, i.y), i.width, i.length,
                facecolor=i.color, edgecolor = 'black')

        clearance = patches.FancyBboxPatch((i.x, i.y), i.width, i.length, \
                    boxstyle = patches.BoxStyle('round', pad = meters),
                    color = i.color, alpha = 0.4)

        # add building to visual grid
        ax.add_artist(temp)
        ax.add_artist(clearance)
示例#4
0
    def init_fig(self, num):
        self.spots = []
        self.spots_text_num = []
        h_interval = 0.2
        v_interval = 0.2

        for i in range(16):
            x = 0.03 + int(i % 4) * h_interval
            y = 0.64 - int(i // 4) * v_interval
            s = mpatches.FancyBboxPatch([x, y],
                                        0.15,
                                        0.15,
                                        facecolor="white",
                                        boxstyle=mpatches.BoxStyle("square",
                                                                   pad=0.01))

            self.spots.append(s)
            t = self.ax.text(x + 0.02,
                             y + 0.04,
                             str(num[i]),
                             fontsize=14,
                             fontweight="bold")
            self.spots_text_num.append(t)

        self.ax.set_xlim(0, 0.8)
        self.ax.set_ylim(0, 0.8)
        collection = PatchCollection(self.spots)
        self.spots = self.ax.add_collection(collection)
        self.spots.set_facecolors('white')
        self.spots.set_edgecolors('gray')
示例#5
0
def makeFancyBox(x, y, width, height):
    fancybox = mpatches.FancyBboxPatch([x, y],
                                       width,
                                       height,
                                       boxstyle=mpatches.BoxStyle("Round",
                                                                  pad=1))
    patches.append(fancybox)
示例#6
0
    def animation(self):
        for obstacle in self.obstacles:
            obs = mpatches.FancyBboxPatch(
                (obstacle[0] - obstacle[2] / 2, obstacle[1] - obstacle[2] / 2),
                obstacle[2],
                obstacle[2],
                boxstyle=mpatches.BoxStyle("Round", pad=0.01),
                color='red')
            self.ax.add_patch(obs)

        self.ax.plot(self.goal[0], self.goal[1], "xr")
        self.ax.plot(self.start[0, 0], self.start[1, 0], "ob")

        for node in self.nodes:
            if node[3] != None:
                plt.plot([node[0], self.nodes[node[3]][0]],
                         [node[1], self.nodes[node[3]][1]], "-k")

#        self.ax.axis('equal')

        self.ax.set_xlim(-20, 20)
        self.ax.set_ylim(-20, 20)

        plt.xlabel('x [m]')
        plt.ylabel('y [m]')
        plt.title('RRT* Planner')
        #        if self.itr%5 == 0:
        #        plt.savefig("images/"+ str(self.itr) +".png")
        self.itr += 1
        plt.pause(0.001)
示例#7
0
def rounded_rect_patch(x, y, width, height):
    fancybox = mpatches.FancyBboxPatch((x, y),
                                       width,
                                       height,
                                       boxstyle=mpatches.BoxStyle("Round",
                                                                  pad=0.02))

    return fancybox
示例#8
0
def fancybox(ax,loc,heigt,width,color,alpha):
    patches=[]
    fancybox = mpatches.FancyBboxPatch(
        loc, height, width,
        boxstyle=mpatches.BoxStyle("square", pad=0))
    patches.append(fancybox)
    collection = PatchCollection(patches, cmap=plt.cm.hsv, alpha=alpha,edgecolor="none",facecolor=color)
    ax.add_collection(collection)
示例#9
0
    def draw_wire(self, x1, y1, x2, y2, color, linewidth):

        length = np.sqrt(((x2-x1)**2)+ ((y2-y1)**2))
        degrees = math.degrees(math.atan2(y2-y1, x2-x1))
        fancybox = FancyBboxPatch([x1, y1], linewidth, length, boxstyle=mpatches.BoxStyle("Round"), mutation_scale=0.2,
                                  mutation_aspect=1, color=color)
        t = mpl.transforms.Affine2D().rotate_deg(degrees)
        fancybox.set_transform(t)
        self.axes.add_patch(fancybox)
示例#10
0
    def draw_chromosome(self, side):
        tmp=self.ch_graph_start_coord
        if side=='3':
            self.ch_graph_start_coord=self.ch_graph_start_coord+1.0
        if side=='4':
            self.ch_graph_start_coord=self.ch_graph_start_coord+0.5

        #changed add /scale make it shorter
        scale = 1.0
        if side =='5':
            scale = scale_5
        else:
            scale = scale_3

        acen_start = int(next(region for region in self.ch_regions if region[4] == 'acen')[1])
        acen_end = int(next(region for region in list(reversed(self.ch_regions)) if region[4] == 'acen')[2])

        self.arm_length_left = float(acen_start)/self.ch_length/scale
        self.arm_length_right = (self.ch_length - float(acen_end))/self.ch_length/scale

        #changed
        if side =='5':
            self.acen_length_5 = acen_end - acen_start
        else:
            self.acen_length_3 = acen_end - acen_start

        self.centrolmere_x = self.ch_graph_start_coord + self.arm_length_left + self.centrolmere_radius + self.pad_size

        centrolmere = patches.Circle((self.centrolmere_x, self.centrolmere_y), self.centrolmere_radius, ec="none", color = "black")

        chrom_arm_1 = patches.FancyBboxPatch(
            (self.centrolmere_x + 0.05, self.centrolmere_y - self.arm_width/2), self.arm_length_right, self.arm_width,
            facecolor= "gray", ec = "black",
            boxstyle=patches.BoxStyle("Round", pad = self.pad_size))

        chrom_arm_2 = patches.FancyBboxPatch(
            (self.centrolmere_x - 0.05 - self.arm_length_left, self.centrolmere_y - self.arm_width/2), self.arm_length_left, self.arm_width,
            facecolor= "gray", ec = "black",
            boxstyle=patches.BoxStyle("Round", pad = self.pad_size))

        self.ax.add_patch(chrom_arm_1)
        self.ax.add_patch(chrom_arm_2)
        self.ax.add_patch(centrolmere)
        self.ch_graph_start_coord=tmp
def draw_tree(draw_info):
    patches = []

    fig, ax = plt.subplots(figsize=(18, 12))

    timer = fig.canvas.new_timer(
        interval=10000
    )  # creating a timer object and setting an interval of 10 sec
    timer.add_callback(close_event)
    lines = []
    text_size = 14
    box_width = 10
    for node in draw_info.values():
        x_coord = node[1]
        y_coord = node[2]
        text = node[0]
        if len(node) > 3:
            l1_x_coord = node[3]
            l1_y_coord = node[4]
            l2_x_coord = node[5]
            l2_y_coord = node[6]
        this_node = mpatches.FancyBboxPatch(xy=[x_coord, y_coord],
                                            width=box_width,
                                            height=1,
                                            boxstyle=mpatches.BoxStyle("Round",
                                                                       pad=4))
        patches.append(this_node)
        # last_node = last_node_coords[node//2]
        line = mlines.Line2D(
            [l1_x_coord + (box_width // 2), l2_x_coord + (box_width // 2)],
            [l1_y_coord, l2_y_coord + 1])
        lines.append(line)
        plt.text(x_coord + 5,
                 y_coord,
                 text,
                 ha="center",
                 family='sans-serif',
                 size=text_size)

    colors = np.linspace(0, 1, len(patches))
    collection = PatchCollection(patches, cmap=plt.cm.hsv, alpha=0.3)
    collection.set_array(np.array(colors))
    ax.add_collection(collection)
    for line in lines:
        ax.add_line(line)

    plt.axis('equal')
    plt.axis('off')
    plt.tight_layout()
    plt.ion()
    # timer.start()
    plt.savefig(f'{DOMAIN}_expert_policy.png')

    plt.show()
    # timer.stop()
    plt.pause(0.01)
示例#12
0
def plot_ax4_mean(ax4,
                  fit_pars_portions,
                  fc='none',
                  marker='o',
                  label='clds mean',
                  s=90,
                  ls='--',
                  lw=1,
                  **kwargs):
    #I wanted to draw the mean of the portions as a tiny pie, however it seems to over-saturate the image with info.
    fit_pars = np.asarray(fit_pars_portions)
    center = np.average(fit_pars[:, 0:2], axis=0, weights=data_size[ids_bool])
    std_dv = np.sqrt(
        np.average((fit_pars[:, 0] - center[0])**2,
                   weights=data_size[ids_bool]))
    std_alpha = np.sqrt(
        np.average((fit_pars[:, 1] - center[1])**2,
                   weights=data_size[ids_bool]))

    ax4.scatter(*center,
                facecolors=fc,
                marker=marker,
                s=s,
                edgecolors='black',
                alpha=1.0,
                label=label,
                linestyles=ls,
                linewidths=lw,
                **kwargs)

    add_label(ax4, (0.25, 0.199),
              r'$\sigma_{\upsilon_0}=%.2f$, $\sigma_\alpha=%.2f$ from ' %
              (std_dv, std_alpha),
              fontsize=SMALL_SIZE,
              transform=ax4.transAxes)
    ax4.scatter(0.5,
                0.2105 - 0.15,
                facecolors=fc,
                marker=marker,
                s=s,
                edgecolors='black',
                alpha=1.0,
                linestyles=ls,
                linewidths=lw,
                transform=ax4.transAxes,
                **kwargs)

    patch = mpatches.FancyBboxPatch(
        (0.01, 0.01),
        0.53,
        0.1,
        facecolor='none',
        linewidth=1.4,
        transform=ax4.transAxes,
        boxstyle=mpatches.BoxStyle("Round", pad=0.0, rounding_size=0.03))
    ax4.add_artist(patch)
示例#13
0
    def __init__(self,
                 xy,
                 width,
                 height,
                 boxstyle='Round',
                 pad=0.3,
                 corner_size=None,
                 **kwargs):
        if boxstyle in ['Roundtooth', 'Sawtooth']:
            bs = patches.BoxStyle(boxstyle, pad=pad, tooth_size=corner_size)
        elif boxstyle in ['Round', 'Round4']:
            bs = patches.BoxStyle(boxstyle, pad=pad, rounding_size=corner_size)
        else:
            bs = patches.BoxStyle(boxstyle, pad=pad)

        super().__init__(xy=(xy[0] + pad, xy[1] + pad),
                         width=width - 2 * pad,
                         height=height - 2 * pad,
                         boxstyle=bs,
                         **kwargs)
示例#14
0
    def draw(self, ax):

        if not self.rounded:
            boxstyle = patches.BoxStyle('square', pad=self.pad)
        else:
            boxstyle = patches.BoxStyle('round', pad=self.pad)

        if self.label:
            ax.text(x=self.start + 0.5 * self.width,
                    y=0.5 * (self.top + self.bottom),
                    s=self.label,
                    **self.label_kwargs)

        box = patches.FancyBboxPatch(xy=(self.start + self.pad, self.top),
                                     width=self.width - 2 * self.pad,
                                     height=self.bottom - self.top,
                                     boxstyle=boxstyle,
                                     fc=self.colour,
                                     ec='k')

        ax.add_artist(box)

        return ax
示例#15
0
def rectangle(xy, size, angle, roundness, **kwargs):
    '''width is relative width with respect to height.'''
    if np.ndim(size) == 0:
        size = (size, size)
    width, height = 2 * size[0], 2 * size[1]
    xy_ = xy[0] - width / 2., xy[1] - height / 2.
    if roundness != 0:
        pad = roundness
        c = patches.FancyBboxPatch(xy_ + np.array([pad, pad]),
                                   width - pad * 2,
                                   height - pad * 2,
                                   boxstyle=patches.BoxStyle("Round", pad=pad),
                                   **_fix(kwargs))
    else:
        c = patches.Rectangle(xy_, width, height, **_fix(kwargs))
    return [c]
示例#16
0
    def init_figure(self):
        ''' initial drawing '''

        common_keys = dict(va='baseline', ha="center")
        kwargs = dict(fc=self.bg, ec=self.normal, lw=1.5)

        # 10W Label
        self.axes.text(0.1,
                       0.3,
                       "10W",
                       common_keys,
                       size=11,
                       color=self.normal)

        # 10W frame
        bs = mpatches.BoxStyle("Round4", pad=0.05)
        self.frame_10w = mpatches.FancyBboxPatch((0.046, 0.2), 0.11, 0.6, \
                                          boxstyle=bs, **kwargs)
        self.axes.add_patch(self.frame_10w)

        # 600W Label
        self.axes.text(0.36,
                       0.3,
                       "600W",
                       common_keys,
                       size=11,
                       color=self.normal)

        # 600# frame
        self.frame_600w = mpatches.FancyBboxPatch((0.3, 0.2), 0.11, 0.6, \
                                          boxstyle=bs, **kwargs)
        self.axes.add_patch(self.frame_600w)

        self.axes.set_ylim(min(self.y_scale), max(self.y_scale))
        self.axes.set_xlim(min(self.x_scale), max(self.x_scale))
        # # disable default x/y axis drawing
        #self.axes.set_xlabel(False)
        #self.axes.apply_aspect()
        self.axes.set_axis_off()

        #self.axes.set_xscale(10)
        #self.axes.axison=False
        self.draw()
示例#17
0
def CAPatches(label="abbrev",
              data_labels=[],
              data_fmt="%s",
              font_size="small",
              scale=[]):
    """Returns a matplotlib collection of patches. Also makes labels by default."""

    patches = []

    if len(data_labels) > 0 and len(data_labels) != 77:
        raise ValueError, "Must have 77 labels"
    if not len(data_labels) > 0:
        data_labels = [None] * 77
    if not len(scale) > 0:
        scale = [1] * 77

    for carea, data_label, sc in zip(CAreaGrid, data_labels, scale):
        # Add a fancy box
        fancybox = mpatches.FancyBboxPatch(
            [carea.gridloc[0] - 0.5, carea.gridloc[1] - 0.75],
            0.8 * sc,
            0.8 * sc,
            boxstyle=mpatches.BoxStyle("Round", pad=0.05))
        # if data_label:
        #    plt.text(carea.gridloc[0], carea.gridloc[1] - .5, data_fmt % data_label, ha="center", size=font_size)
        if label == "abbrev":
            plt.text(carea.gridloc[0],
                     carea.gridloc[1],
                     name_to_abbrev(carea.name),
                     ha="center",
                     size=font_size)
        elif label == "number":
            plt.text(carea.gridloc[0],
                     carea.gridloc[1],
                     carea.n,
                     ha="center",
                     size="small")
        patches.append(fancybox)
    return PatchCollection(patches)
"""
示例#19
0
    y_loc = Y_START_LOC
    width = 10
    x_ticks.append(x_loc + width / 2)
    for graph_type in step_shapes.keys():
        if graph_type == "select" or graph_type == "None":
            step_shapes[graph_type][item] = None
            continue
        elif not graph_type.startswith("full") and item.startswith("Paper"):
            height = 60 * (1 - 1 / N_MODELS)
        else:
            height = 60
        step_shapes[graph_type][item] = mpatches.FancyBboxPatch(
            (x_loc, y_loc),
            width,
            height,
            boxstyle=mpatches.BoxStyle("Round", pad=2.5),
            facecolor="DarkSeaGreen",
            edgecolor="none",
            alpha=0.75,
        )

# Add stuff 'manually' to select graph.
step_shapes["select"]["single boxes"] = []
for x_count in range(N_STEPS):
    x_loc = x_count * X_UNIT + X_START_LOC
    for y_count in range(N_MODELS):
        y_loc = y_count * Y_UNIT + Y_START_LOC
        if x_count in {1, 2}:
            height = 20
        elif x_count in {0, 3} and y_count == 0:
            height = 2 * (20 + 20 / N_MODELS)
path_data = [(Path.MOVETO, [0.018, -0.11]), (Path.CURVE4, [-0.031, -0.051]),
             (Path.CURVE4, [-0.115, 0.073]), (Path.CURVE4, [-0.03, 0.073]),
             (Path.LINETO, [-0.011, 0.039]), (Path.CURVE4, [0.043, 0.121]),
             (Path.CURVE4, [0.075, -0.005]), (Path.CURVE4, [0.035, -0.027]),
             (Path.CLOSEPOLY, [0.018, -0.11])]
codes, verts = zip(*path_data)
path = mpath.Path(verts + grid[6], codes)
patch = mpatches.PathPatch(path)
patches.append(patch)
label(grid[6], "PathPatch")

# add a fancy box
fancybox = mpatches.FancyBboxPatch(grid[7] - [0.025, 0.05],
                                   0.05,
                                   0.1,
                                   boxstyle=mpatches.BoxStyle("Round",
                                                              pad=0.02))
patches.append(fancybox)
label(grid[7], "FancyBoxPatch")

# add a line
x, y = np.array([[-0.06, 0.0, 0.1], [0.05, -0.05, 0.05]])
line = mlines.Line2D(x + grid[8, 0], y + grid[8, 1], lw=5., alpha=0.3)
label(grid[8], "Line2D")

colors = np.linspace(0, 1, len(patches))
collection = PatchCollection(patches, cmap=plt.cm.hsv, alpha=0.3)
collection.set_array(np.array(colors))
ax.add_collection(collection)
ax.add_line(line)

plt.subplots_adjust(left=0, right=1, bottom=0, top=1)
示例#21
0
    def init_figure(self):
        ''' initial drawing '''

        common_keys = dict(va='baseline', ha="center", color=self.normal, size=11)       
        w = 0.11
        h = 0.6 
   
        kargs = dict(fc=self.bg, ec=self.normal, lw=1.5) 
        # Th-Ar1 Label
        self.axes.text(0.11, 1.2, "Th-Ar1", common_keys)

        # Th-Ar1 frame
        bs = mpatches.BoxStyle("Round4", pad=0.05) 
        self.th_ar1 = mpatches.FancyBboxPatch((0.05, 1.1), w, h, \
                                          boxstyle=bs, **kargs)
        self.axes.add_patch(self.th_ar1)

        # Th-Ar2 Label
        self.axes.text(0.11, 0.25, "Th-Ar2", common_keys)

        # Th-Ar2 frame
        self.th_ar2 = mpatches.FancyBboxPatch((0.05, 0.2), w, h, \
                                          boxstyle=bs, **kargs)
        self.axes.add_patch(self.th_ar2)

        # Ne Label
        self.axes.text(0.36, 1.2, "Ne", common_keys)

        # Ne frame
        self.ne = mpatches.FancyBboxPatch((0.3, 1.1), w, h, \
                                          boxstyle=bs, **kargs)
        self.axes.add_patch(self.ne)

        # Ar Label
        self.axes.text(0.36, 0.25, "Ar", common_keys)

        # ar frame
        self.ar = mpatches.FancyBboxPatch((0.3, 0.2), w, h, \
                                          boxstyle=bs, **kargs)
        self.axes.add_patch(self.ar)

        # hal1 Label
        self.axes.text(0.6, 1.2, "Hal1", common_keys)

        # hal1 frame
        self.hal1 = mpatches.FancyBboxPatch((0.55, 1.1), w, h, \
                                          boxstyle=bs, **kargs)
        self.axes.add_patch(self.hal1)

        # hal2 Label
        self.axes.text(0.6, 0.25, "Hal2", common_keys)

        # hal2 frame
        self.hal2 = mpatches.FancyBboxPatch((0.55, 0.2), w, h, \
                                          boxstyle=bs, **kargs)
        self.axes.add_patch(self.hal2)

        self.axes.set_ylim(min(self.y_scale), max(self.y_scale))
        self.axes.set_xlim(min(self.x_scale), max(self.x_scale))
        # # disable default x/y axis drawing 
        #self.axes.set_xlabel(False)
        #self.axes.apply_aspect()
        self.axes.set_axis_off()
       
        #self.axes.set_xscale(10)
        #self.axes.axison=False
        self.draw()
示例#22
0
def draw_gene_isoforms(D, gene_id, outfile, outfmt):

  import matplotlib.patches as mpatches;
  from matplotlib.collections import PatchCollection;

  ISO = D[_.orig_gene == gene_id].GroupBy(_.alt_gene).Without(_.orig_gene, _.orig_exon_start, _.orig_exon_end).Sort(_.alt_gene);

  plt.cla();

  y_loc   = 0;
  y_step  = 30;
  n_iso   = ISO.alt_gene.Shape()();
  origins = np.array([ [0, y] for y in xrange((y_step * (n_iso+1)),n_iso,-y_step) ]);
  patch_h = 10;

  xlim = [ ISO.exon_start.Min().Min()(), ISO.exon_end.Max().Max()()];
  ylim = [ y_step, (y_step * (n_iso+1)) + 2*patch_h];

  patches = [];
  
  for (origin, alt_id, starts, ends, exons, retention, alt5, alt3, skipped, new, ident) in zip(origins, *ISO()):

    plt.gca().text( min(starts), origin[1] + patch_h, alt_id, fontsize=10);
    for (exon_start, exon_end, exon_coverage, exon_retention, exon_alt5, exon_alt3, exon_skipped, exon_new, exon_ident) in zip(starts, ends, exons, retention, alt5, alt3, skipped, new, ident):
      if not(exon_skipped):
        patch = mpatches.FancyBboxPatch(origin + [ exon_start, 0], exon_end - exon_start, patch_h, boxstyle=mpatches.BoxStyle("Round", pad=0), color=draw_gene_isoforms_color(exon_retention, exon_alt5, exon_alt3, exon_skipped, exon_new, exon_ident));
        text_x, text_y = origin + [ exon_start, +patch_h/2];
        annots = zip(['Retention', "Alt 5'", "Alt 3'", "Skipped", 'New'], [exon_retention, exon_alt5, exon_alt3, exon_skipped, exon_new]);
        text  = '%s: %s' %( ','.join([str(exid) for exid in exon_coverage]), '\n'.join([ s for (s,b) in annots if b]));
        plt.gca().text(text_x, text_y, text, fontsize=10, rotation=-45);
        plt.gca().add_patch(patch);

        if all(ident):
          plt.gca().plot([exon_start, exon_start], [origin[1], 0], '--k', alpha=0.3);
          plt.gca().plot([exon_end, exon_end], [origin[1], 0], '--k', alpha=0.3);
        #fi
      #fi
    #efor
  #efor

  plt.xlim(xlim);
  plt.ylim(ylim);
  plt.title('Isoforms for gene %s' % gene_id);
  plt.xlabel('Location on chromosome');
  plt.gca().get_yaxis().set_visible(False);
  plt.gca().spines['top'].set_color('none');
  plt.gca().spines['left'].set_color('none');
  plt.gca().spines['right'].set_color('none');
  plt.tick_params(axis='x', which='both', top='off', bottom='on');
  plt.savefig(outfile, format=outfmt);

  return ISO;
示例#23
0
    def draw_wordlist(self, ax):
        ax.set(xlim=(0, self.width), ylim=(0, self.height))
        ax.axis("off")

        if self.draw_copyright is True:
            ax.text(self.width,
                    0,
                    '© MakePuzz',
                    size=self.fontsize,
                    ha='right',
                    va='bottom',
                    fontname='Yu Gothic',
                    alpha=0.5,
                    fontweight='bold')

        if self.w_num == 0:
            return ax

# write list
        box = {
            "fc": "#f5efe6",  # facecolor
            "ec": "darkgray",  # edgecolor
            "style": mpatches.BoxStyle("Round", pad=0.05 * self.fontsize / 30),
            "size": 0.15 * self.fontsize / 30,
            "difx":
            0.3 * self.fontsize / 30,  # difference from word_x to draw box
            "dify":
            0.25 * self.fontsize / 30,  # difference from word_y to draw box
        }
        label = {
            "difx": 0.55 * self.fontsize /
            30,  # difference from word_x to draw the label
            "dify": 0.2 * self.fontsize /
            30,  # difference from word_y to draw the label
            "size": 14 * self.fontsize / 30,  # label font size
            "color": "dimgray",
        }
        labelline = {
            "difx": 0.45 * self.fontsize /
            30,  # difference from word_x to draw the label line
            "width": 3 * self.fontsize / 30,  # line width
            # "space": self.char_max_per_row / (int(self.height / self.inch_of(self.fontsize)) - 6),
            "space": 1.4,
            "ymin_dif": self.inch_of(self.fontsize) *
            0.8,  # coefficient of ymin when drawing a label
            "ymax_dif": 0.05 * self.fontsize /
            30  # coefficient of ymax when drawing a label
        }

        # k: array number of words, j: column number, i: row number
        k = 0
        word_x = self.inch_of(self.fontsize) * 2
        ymax_default = (self.height * 0.995 -
                        labelline["ymax_dif"]) / self.height
        for j in range(self.col_num):
            if j > 0:
                word_x += (self.w_lens[self.row_num * j] + 2) * self.inch_of(
                    self.fontsize)
            ymax = ymax_default
            for i in range(self.row_num):
                if k == self.w_num:
                    break
                word_y = self.height * 0.995 - i * self.inch_of(
                    self.fontsize) * labelline["space"]
                # box
                if self.draw_box is True:
                    fancybox = mpatches.FancyBboxPatch(
                        (word_x - box["difx"], word_y - box["dify"]),
                        box["size"],
                        box["size"],
                        boxstyle=box["style"],
                        fc=box["fc"],
                        ec=box["ec"],
                        alpha=1)
                    ax.add_patch(fancybox)

                # main word
                ax.text(word_x,
                        word_y,
                        self.words[k],
                        size=self.fontsize,
                        ha="left",
                        va="top")

                # label
                if self.draw_label is True:
                    if k == 0 or self.w_lens[k] > self.w_lens[k - 1]:
                        ax.text(word_x - label["difx"],
                                word_y - label["dify"],
                                str(self.w_lens[k]),
                                fontsize=label["size"],
                                color=label["color"],
                                ha="right")

                # label line
                if self.draw_labelline is True:
                    if i != 0 and self.w_lens[k] > self.w_lens[k - 1]:
                        ymin = (self.height * 0.995 -
                                (i - 1) * self.inch_of(self.fontsize) *
                                labelline["space"] -
                                labelline["ymin_dif"]) / self.height
                        ax.axvline(x=word_x - labelline["difx"],
                                   color="lightgray",
                                   ymin=ymin,
                                   ymax=ymax,
                                   lw=labelline["width"])
                        ymax = (word_y - labelline["ymax_dif"]) / self.height
                k += 1
            if self.draw_labelline is True:
                if j == self.col_num - 1 and k == self.w_num and self.w_num % self.row_num != 0:
                    ymin = (self.height * 0.995 - self.inch_of(self.fontsize) *
                            (i - 1) * labelline["space"] -
                            labelline["ymin_dif"]) / self.height
                else:
                    ymin = (self.height * 0.995 - self.inch_of(self.fontsize) *
                            (i) * labelline["space"] -
                            labelline["ymin_dif"]) / self.height
                ax.axvline(x=word_x - labelline["difx"],
                           color="lightgray",
                           ymin=ymin,
                           ymax=ymax,
                           lw=labelline["width"])
        return ax
示例#24
0
def main():
    df = pd.read_csv("../analysis/csv/uc-lattice-final-params.csv",
                     index_col=0)
    df = df[df.temperature == 10]
    dff = pd.read_csv("../analysis/csv/ap-final-2.csv", index_col=0)
    seaborn.set_palette('bright', n_colors=len(df))
    #data = values_real_to_scaled(df[list(AP.param_names)].values, AP.param_bounds)
    #data_f = values_real_to_scaled(dff[list(AP.param_names)].values, AP.param_bounds)
    data = df[list(AP.param_names)].values
    data_f = dff[list(AP.param_names)].values
    result_bounds = np.array([[0, 0.5], [0, 5]])
    results = values_real_to_scaled(
        df[["uc_mean_distance", "lattice_ape"]].values, result_bounds)
    results_f = values_real_to_scaled(
        dff[["uc_mean_distance", "lattice_ape"]].values, result_bounds)
    param_bounds = AP.param_bounds
    param_bounds[:4] = param_bounds[:4]  #* NM_TO_ANGSTROM
    param_bounds[4:] = param_bounds[4:]  #* KJMOL_TO_K

    data = np.hstack((data, results))
    data_f = np.hstack((data_f, results_f))
    bounds = np.vstack((param_bounds, result_bounds))
    print(data.shape)

    col_names = [
        r"$\sigma_{Cl}$",
        r"$\sigma_H$",
        r"$\sigma_N$",
        r"$\sigma_O$",
        r"$\epsilon_{Cl}$",
        r"$\epsilon_H$",
        r"$\epsilon_N$",
        r"$\epsilon_O$",
        r"UCMD",
        "Lattice\nMAPE",
    ]
    n_axis = len(col_names)
    assert data.shape[1] == n_axis
    x_vals = [i for i in range(n_axis)]

    # Create (N-1) subplots along x axis
    fig, axes = plt.subplots(1, n_axis - 1, sharey=False, figsize=(12, 5))

    # Plot each row
    for i, ax in enumerate(axes):
        for line in data:
            ax.plot(x_vals, line, alpha=0.35)
        ax.set_xlim([x_vals[i], x_vals[i + 1]])
        for line in data_f:
            ax.plot(x_vals, line, alpha=1.0, linewidth=3)

    for dim, ax in enumerate(axes):
        ax.xaxis.set_major_locator(ticker.FixedLocator([dim]))
        set_ticks_for_axis(ax, bounds[dim], nticks=6)
        ax.set_xticklabels([col_names[dim]], fontsize=30)
        ax.tick_params(axis="x", pad=10)
        ax.set_ylim(-0.05, 1.05)
        # Add white background behind labels
        for label in ax.get_yticklabels():
            label.set_bbox(
                dict(facecolor='white',
                     edgecolor='none',
                     alpha=0.45,
                     boxstyle=mpatch.BoxStyle("round4")))
        ax.spines['top'].set_visible(False)
        ax.spines['bottom'].set_visible(False)
        ax.spines['left'].set_linewidth(2.0)

    ax = axes[-1]
    ax.xaxis.set_major_locator(ticker.FixedLocator([n_axis - 2, n_axis - 1]))
    ax.set_xticklabels([col_names[-2], col_names[-1]], fontsize=24)
    ax.tick_params(axis="x", pad=14)

    # Add class II data
    #ax.plot(x_vals[-2], 0.3485/bounds[-2][1], markersize=15, color="red", marker="*", clip_on=False, zorder=200)

    ax = plt.twinx(axes[-1])
    ax.set_ylim(-0.05, 1.05)
    set_ticks_for_axis(ax, bounds[-1], nticks=6)
    ax.spines['top'].set_visible(False)
    ax.spines['bottom'].set_visible(False)
    ax.spines['right'].set_linewidth(2.0)

    # Add class I data
    ax.plot(x_vals[-1],
            1.42 / bounds[-1][1],
            markersize=15,
            color="tab:purple",
            marker="o",
            clip_on=False,
            zorder=200)
    ax.plot(x_vals[-2],
            0.156 / bounds[-2][1],
            markersize=15,
            color="tab:purple",
            marker="o",
            clip_on=False,
            zorder=200)

    # Add class II data
    ax.plot(x_vals[-1],
            3.55 / bounds[-1][1],
            markersize=20,
            color="tab:red",
            marker="*",
            clip_on=False,
            zorder=200)
    ax.plot(x_vals[-2],
            0.3485 / bounds[-2][1],
            markersize=20,
            color="tab:red",
            marker="*",
            clip_on=False,
            zorder=200)

    # Remove space between subplots
    plt.subplots_adjust(wspace=0, bottom=0.2, left=0.05, right=0.95)

    fig.savefig("pdfs/fig4-ap-parallel.pdf")
示例#25
0
from matplotlib.collections import PatchCollection

fig = plt.figure(figsize=(4.25, 4.25 * 95 / 115))
ax = fig.add_axes([0, 0, 1, 1],
                  frameon=False,
                  aspect=1,
                  xlim=(0 - 5, 100 + 10),
                  ylim=(-10, 80 + 5),
                  xticks=[],
                  yticks=[])

box = mpatches.FancyBboxPatch((0, 0),
                              100,
                              83,
                              mpatches.BoxStyle("Round",
                                                pad=0,
                                                rounding_size=2),
                              linewidth=1.,
                              facecolor="0.9",
                              edgecolor="black")
ax.add_artist(box)

box = mpatches.FancyBboxPatch((0, 0),
                              100,
                              75,
                              mpatches.BoxStyle("Round",
                                                pad=0,
                                                rounding_size=0),
                              linewidth=1.,
                              facecolor="white",
                              edgecolor="black")
示例#26
0
plt.rcParams['ps.useafm'] = True
plt.rcParams['pdf.use14corefonts'] = True
plt.rcParams['text.usetex'] = True

########################
contalpha = 0.5
wallthick = 0.5
wallalpha = 0.25
wallcolor = '#2e3436'
heateralpha = 0.4
heatercolor = '#3465A4'

omegazdict = {
    'width': 2,
    'height': 2,
    'boxstyle': patches.BoxStyle('Round', pad=0.15),
    'linewidth': 1.0,
    'color': 'black',
    'zorder': 15,
    'fill': False
}
heaterdict = {
    'width': 1,
    'height': 1,
    'boxstyle': patches.BoxStyle('Round', pad=0.15),
    'linewidth': 1.0,
    'edgecolor': 'black',
    'alpha': heateralpha,
    'facecolor': heatercolor,
    'zorder': 5,
    'fill': True
示例#27
0
def Plot_SeismicPatchNet_topologyV1_evolution(num_models_plot, performance_table, 
                                              fig_width=11, fig_height=12, font_size=12, 
                                              fig_title="", window_title="Evolution"):
    import matplotlib.patches as mpatches
    from matplotlib.collections import PatchCollection
    from matplotlib.collections import LineCollection
    
    # data
    step = int(len(performance_table)/num_models_plot)
    select_indexes = np.arange(0, len(performance_table)-1, step)
    performance_table = performance_table.loc[select_indexes,:]
    performance_table = performance_table.sort_values(['mean top5'], ascending=True) # the last one is the BEST
    performance_table = performance_table.reset_index(drop=True)
    num_of_item = len(performance_table)
    
    # geometry
    unit_width_range = [50, 150]
    unit_height_range = [50, 150]
    unit_keys = ["conv0 output size", "conv1 output size", "conv2 output size", 
                 "perception_3 output size", "perception_4 output size", "perception_5 output size"]   
    center_xy_start = [0, 0]
    y_step = 250
    
    # analysis
    print("\n\n Analyzing data ...")
    keys_value_range_dict = statistics_Keys_value_range(unit_keys, performance_table["model structure"].to_list())
    structure_table = pd.DataFrame() # unit sizes to be plotted
    for i in tqdm(np.arange(num_of_item)):
        models_structure = performance_table.loc[i, "model structure"]
        models_structure = ast.literal_eval(models_structure)
        plot_dict = {key: models_structure[key] for key in unit_keys}
        structure_table = structure_table.append(plot_dict, ignore_index=True)
    structure_table.insert(0, 'mean top5', performance_table['mean top5'])
        
    # plot status   
    print("\n\n Ploting models evolution ...")
    # color scheme
    if num_of_item==1: num_of_color = 2
    else: num_of_color = num_of_item
    cmap = plt.get_cmap("rainbow") # "rainbow", 'Reds'
    colors = [cmap(i) for i in np.linspace(0, 1, num_of_color)]
    
    
#    #--------------------- generate figure: unit shape -----------------------#
    fig_shape, axis_shape = subPlotDefi(windowTitle="{}: shape".format(window_title), figSizeCM=(fig_width, fig_height), 
                             subAdjust=(0.15, 0.85, 0.1, 0.85), axLabelSize=font_size, axTickSize=font_size)   
    # evolution
    x_max = 0
    for i in tqdm(np.arange(num_of_item)):
        plot_structure = structure_table.iloc[i]
        
        # if it is the best one
        if i==num_of_item-1:
            Linewidth = 2 
            Edgecolor = 'black' # colors[i]
            Alpha = 0.9
        else:
            Linewidth = 1.8    
            Edgecolor=colors[i]
            Alpha = 0.7
            
        key_ix=0
        for key in unit_keys:
            value = plot_structure[key]
            box_width = ((value - min(keys_value_range_dict[key])) / (max(keys_value_range_dict[key]) - min(keys_value_range_dict[key]))) * (max(unit_width_range) - min(unit_width_range)) + min(unit_width_range)
            box_height = ((value - min(keys_value_range_dict[key])) / (max(keys_value_range_dict[key]) - min(keys_value_range_dict[key]))) * (max(unit_height_range) - min(unit_height_range)) + min(unit_height_range)
            if x_max < box_width:
                x_max = box_width
            fancybox = mpatches.FancyBboxPatch(
                    lowerleft_corner_of_box((center_xy_start[0], center_xy_start[1]+key_ix*y_step), box_width, box_height),
                    box_width, box_height, facecolor="None", edgecolor=Edgecolor, linewidth=Linewidth, alpha=Alpha,
                    boxstyle=mpatches.BoxStyle("Round", pad=8), zorder=i)
            key_ix += 1
            axis_shape.add_patch(fancybox)
            
    
    axis_shape.set_xlim(xmin = -x_max*1.2/2, xmax = x_max*1.2/2)
    axis_shape.set_ylim(bottom = -max(unit_height_range), top = y_step*len(keys_value_range_dict)*0.92)
    axis_shape.set_xticks([]) 
    axis_shape.set_yticks([])
    axis_shape.set_title(fig_title)
    # Colorbar
    vmin = performance_table["mean top5"].min()    # colorbar lower limit
    vmax = performance_table["mean top5"].max()   # colorbar upper limit
    sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(vmin=vmin, vmax=vmax))
    sm._A = []
    cbar = plt.colorbar(sm, ticks=np.round(np.linspace(vmin, vmax, 5), 4))
    cbar.ax.set_ylabel('acc.: mean top5')
    
    
    #--------------------- generate figure: size curve -----------------------#
    fig_curve, axis_curve = subPlotDefi(windowTitle="{}: curve".format(window_title), figSizeCM=(fig_width, fig_height), 
                             figShape=(len(unit_keys)+1, 1), subAdjust=(0.15, 0.85, 0.1, 0.85), 
                             subSpace=(0.25,1), axLabelSize=font_size, axTickSize=font_size)   
    # lines
    x = structure_table["mean top5"].values  
    for i in np.arange(len(unit_keys)):
        y = structure_table[unit_keys[i]].values
        subfig_pos = len(unit_keys)- 1 - i
        axis_curve[subfig_pos].plot(x, y, color="#80DEEA", alpha=0.7, lw=1, zorder=1)
    # colorful scatter
    for i in np.arange(num_of_item):
        scatter_x = structure_table.loc[i, "mean top5"]
        sizes = structure_table.loc[i, unit_keys].values
        for j in np.arange(len(unit_keys)):
            y = sizes[j]
            subfig_pos = len(unit_keys)- 1 - j
            axis_curve[subfig_pos].scatter(scatter_x, y, color=colors[i], s=10, alpha=1, zorder=2)
    # histogram
    Bins=int(len(x)/5)
    if len(x)<25:
        Bins=int(len(x)/2)
    axis_curve[-1].hist(x, bins=Bins, color="#26C6DA")
    # final format
    best_size = structure_table.iloc[-1][unit_keys].values   # best result   
    for k in np.arange(len(unit_keys)):
        subfig_pos = len(unit_keys)- 1 - k
        axis_curve[subfig_pos].scatter(structure_table["mean top5"].values[-1], 
                                      best_size[k], 
                                      edgecolor=Edgecolor, color="None", s=11, linewidths=1.2, alpha=Alpha, zorder=3)  
        axis_curve[subfig_pos].set_title(unit_keys[k], color='black')
#        axis_curve[subfig_pos].xaxis.set_tick_params(labelsize=10)     
        axis_curve[subfig_pos].set_xticks([])
    axis_curve[-1].set_xlabel("mean acc.")
    axis_curve[-1].xaxis.set_tick_params(labelsize=font_size)
    axis_curve[-1].set_title("performance distribution", color='black')
    fig_curve.text(0.02, 0.5, 'size', fontsize=font_size, va='center', rotation='vertical')   
    fig_curve.suptitle(fig_title)   

    return fig_shape, fig_curve 
示例#28
0
    ax = fig.add_subplot(2, 1, 1)

    epsilon = 0.05
    [phi_arr, power_arr, noanswer_arr] = get_power_curve_fc(phi0, m, delta, epsilon0, epsilon, repetitions)
    ax.plot(phi_arr,power_arr, color="b",linewidth=3.0, label="$(\epsilon = %g $)" % epsilon )
    #ax.plot(phi_arr,noanswer_arr, color="b",linewidth=5.0, label="" , linestyle='-.' )

    epsilon = 0.01
    [phi_arr, power_arr, noanswer_arr] = get_power_curve_fc(phi0, m, delta, epsilon0, epsilon, repetitions)
    ax.plot(phi_arr,power_arr, color="r",linewidth=3.0, label="$(\epsilon = %g $)" % epsilon )
    #ax.plot(phi_arr,noanswer_arr, color="r",linewidth=5.0, label="" , linestyle='-.' )

    # ax.plot([phi0-epsilon0,phi0-epsilon0],[0,1], color="b", linewidth=2.0, label="", linestyle='--')
    # ax.plot([phi0+epsilon0,phi0+epsilon0],[0,1], color="b", linewidth=2.0, label="", linestyle='--')
    fancy = mpatches.FancyBboxPatch([phi0-epsilon0, 0.0], 2*epsilon0, 1.0, alpha=0.3, color="g",
                                    boxstyle=mpatches.BoxStyle("Round", pad=0.0), label="$H_0$")
    ax.add_patch(fancy)

    plt.rcParams.update({'font.size': 18})
    plt.grid()
    if (loopi==1):
        plt.legend(loc=5, fontsize=15)
    loopi += 1
    plt.xlabel("$\phi$", fontsize=30)
    plt.ylabel("Power", fontsize=25)
    #plt.show()
    plt.xlim([np.max([0.0, phi0-0.15]),np.min([phi0+0.15, 1.0])])
    plt.ylim([-0.01,1.01])


示例#29
0
    def plot_car(self, x, y, yaw, steer=0.0, car_length=4.5):
        # Vehicle parameters
        car_width = car_length / 2.25  # [m]
        backwheel = car_length / 4.5  # [m]
        wheel_length = backwheel * 0.5  # [m]
        wheel_width = backwheel * 0.3  # [m]
        wheel_distance = backwheel * 0.7  # [m]
        wheel_offset = backwheel * 2.5  # [m]

        # plot car rectangle
        car = mpatches.FancyBboxPatch((-backwheel, -car_width / 2),
                                      car_width,
                                      car_length,
                                      boxstyle=mpatches.BoxStyle("Round",
                                                                 pad=0.01),
                                      color='red')
        t1 = mpl.transforms.Affine2D().rotate_deg(math.degrees(yaw) - 90.0)
        t2 = mpl.transforms.Affine2D().translate(x, y)
        t = t1 + t2 + self.ax.transData
        car.set_transform(t)
        self.ax.add_patch(car)

        # plot back wheels
        wheel_1 = mpatches.FancyBboxPatch(
            (-wheel_distance - wheel_width / 2, -wheel_length / 2),
            wheel_width,
            wheel_length,
            boxstyle=mpatches.BoxStyle("Round", pad=0.01),
            color='black')

        wheel_2 = mpatches.FancyBboxPatch(
            (wheel_distance - wheel_width / 2, -wheel_length / 2),
            wheel_width,
            wheel_length,
            boxstyle=mpatches.BoxStyle("Round", pad=0.01),
            color='black')

        wheel_1.set_transform(t)
        wheel_2.set_transform(t)

        self.ax.add_patch(wheel_1)
        self.ax.add_patch(wheel_2)

        # plot front wheels
        wheel_3 = mpatches.FancyBboxPatch((-wheel_distance - wheel_width / 2,
                                           wheel_offset - wheel_length / 2),
                                          wheel_width,
                                          wheel_length,
                                          boxstyle=mpatches.BoxStyle("Round",
                                                                     pad=0.01),
                                          color='black')

        wheel_4 = mpatches.FancyBboxPatch((wheel_distance - wheel_width / 2,
                                           wheel_offset - wheel_length / 2),
                                          wheel_width,
                                          wheel_length,
                                          boxstyle=mpatches.BoxStyle("Round",
                                                                     pad=0.01),
                                          color='black')
        tl = mpl.transforms.Affine2D().rotate_around(-wheel_distance,
                                                     wheel_offset, steer)
        tr = mpl.transforms.Affine2D().rotate_around(wheel_distance,
                                                     wheel_offset, steer)

        tl_ = tl + t1 + t2 + self.ax.transData
        tr_ = tr + t1 + t2 + self.ax.transData

        wheel_3.set_transform(tl_)
        wheel_4.set_transform(tr_)

        self.ax.add_patch(wheel_3)
        self.ax.add_patch(wheel_4)
示例#30
0
def gtvctvptv_plot(ax):
    """Plots GTV, CTV, PTV, Treated Volume and Irradiated Volume relations
    diagram.

     @ax: An Axes object to put figure elements on.

    Returns: Default
    """

    ax.add_patch(
        ptchs.FancyBboxPatch((0.25, 0.15),
                             0.5,
                             0.7,
                             boxstyle=ptchs.BoxStyle("Round",
                                                     pad=0.02,
                                                     rounding_size=0.04),
                             fc='#3f8cc6',
                             ec='#3f48c6',
                             zorder=0))
    ax.add_patch(
        ptchs.FancyBboxPatch((0.3, 0.2),
                             0.4,
                             0.6,
                             boxstyle=ptchs.BoxStyle("Round",
                                                     pad=0.02,
                                                     rounding_size=0.04),
                             fc='#3fb4c6',
                             ec='#3f71c6',
                             zorder=1))
    ax.add_patch(
        ptchs.Ellipse((0.5, 0.5),
                      0.35,
                      0.5,
                      fc='#c66780',
                      ec='#c67d67',
                      ls='dotted',
                      zorder=2))
    ax.add_patch(
        ptchs.Ellipse((0.5, 0.5),
                      0.25,
                      0.38,
                      fc='#c63f63',
                      ec='#c65f3f',
                      ls='dashed',
                      zorder=3))
    ax.add_patch(
        ptchs.Ellipse((0.5, 0.5),
                      0.15,
                      0.26,
                      fc='#c61746',
                      ec='#c64017',
                      zorder=4))
    ax.text(0.5,
            0.15,
            u'ozračeni volumen',
            size='large',
            horizontalalignment='center',
            zorder=5)
    ax.text(0.5,
            0.2,
            u'tretirani volumen',
            size='large',
            horizontalalignment='center',
            zorder=5)
    ax.text(0.5,
            0.27,
            u'PTV',
            size='large',
            horizontalalignment='center',
            zorder=5)
    ax.text(0.5,
            0.34,
            u'CTV',
            size='large',
            horizontalalignment='center',
            zorder=5)
    ax.text(0.5,
            0.5,
            u'GTV',
            size='large',
            horizontalalignment='center',
            zorder=5)