def ResidualsPlot(Figure, Time, Signal, FitSolution, Residuals, Noise):

    cFig = Figure
    gridSp = GridSpec(2, 2)

    ax1 = cFig.add_subplot(gridSp[:, 0])
    ax2 = cFig.add_subplot(gridSp[0, 1])
    ax3 = cFig.add_subplot(gridSp[1, 1])

    ax1.plot(Time, Signal, 'ro', label='Data')
    ax1.plot(Time,
             FitSolution,
             label='Regression',
             path_effects=[
                 path_effects.SimpleLineShadow(alpha=0.2, rho=0.2),
                 path_effects.Normal()
             ])
    ax1.legend(loc=0)
    PlotStyle(ax1, 'Fitted Model')

    ax2.plot(Residuals,
             path_effects=[
                 path_effects.SimpleLineShadow(alpha=0.2, rho=0.2),
                 path_effects.Normal()
             ])
    PlotStyle(ax2, 'Residuals')

    ax3.plot(Noise,
             path_effects=[
                 path_effects.SimpleLineShadow(alpha=0.2, rho=0.2),
                 path_effects.Normal()
             ])
    PlotStyle(ax3, 'Noise')

    plt.tight_layout()
Example #2
0
def main():
    gn = Granatum()

    set1 = gn.get_import('set1')
    set2 = gn.get_import('set2')
    set3 = gn.get_import('set3')

    maxScore = gn.get_arg('maxScore')
    minScore = gn.get_arg('minScore')

    labelSet1 = gn.get_arg("labelSet1")
    labelSet2 = gn.get_arg("labelSet2")
    labelSet3 = gn.get_arg("labelSet3")

    wordcloud = gn.get_arg("wordcloud")

    filtered_set1 = dict(filter(lambda elem: (isinstance(elem[1], numbers.Number) & (not isnan(elem[1]))) & (elem[1] >= minScore) & (elem[1] <= maxScore), set1.items()))
    filtered_set2 = dict(filter(lambda elem: (isinstance(elem[1], numbers.Number) & (not isnan(elem[1]))) & (elem[1] >= minScore) & (elem[1] <= maxScore), set2.items()))
    filtered_set3 = dict(filter(lambda elem: (isinstance(elem[1], numbers.Number) & (not isnan(elem[1]))) & (elem[1] >= minScore) & (elem[1] <= maxScore), set3.items()))
    merged_frequencies = {**filtered_set1, **filtered_set2, **filtered_set3}

    packedsets = [set(filtered_set1.keys()), set(filtered_set2.keys()), set(filtered_set3.keys())]

    fig, ax = plt.subplots(1,1)
    fig.set_size_inches(5,4)

    caption = (
        'The area weighted Venn diagram is shown for the gene sets matching the criteria'
    )

    if wordcloud:
        out = venn3_wordcloud(packedsets, set_labels=(labelSet1, labelSet2, labelSet3), wordcloud_kwargs=dict(max_font_size=36), word_to_frequency=merged_frequencies, ax=ax)
        for text in out.set_labels:
            if text:
                text.set_fontsize(18)
        for text in out.subset_labels:
            if text:
                text.set_fontsize(16)
                text.set_path_effects([path_effects.SimpleLineShadow(), path_effects.Normal()])
    else:
        out = venn3(packedsets, set_labels=(labelSet1, labelSet2, labelSet3))
        venn3_circles(packedsets, linestyle='dashed', linewidth=1, color="black")
        for text in out.set_labels:
            if text:
                text.set_fontsize(18)
        for text in out.subset_labels:
            if text:
                text.set_fontsize(16)
                text.set_path_effects([path_effects.SimpleLineShadow(), path_effects.Normal()])

    gn.add_current_figure_to_results(caption)

    gn.commit()
Example #3
0
def test_PathEffect_points_to_pixels():
    fig = plt.figure(dpi=150)
    p1, = plt.plot(range(10))
    p1.set_path_effects([path_effects.SimpleLineShadow(),
                         path_effects.Normal()])

    renderer = fig.canvas.get_renderer()
    pe_renderer = path_effects.SimpleLineShadow().get_proxy_renderer(renderer)

    assert isinstance(pe_renderer, path_effects.PathEffectRenderer)
    # Confirm that using a path effects renderer maintains point sizes
    # appropriately. Otherwise rendered font would be the wrong size.
    assert renderer.points_to_pixels(15) == pe_renderer.points_to_pixels(15)
Example #4
0
def plotClose(dates, cl):
    """
    
    produces a graph of the closing values for each day over 3 months.

    Arguments:
        dates: Datetime object list representing stock dates
#       cl: List of floats representing closing values for each date

    """
    plt.figure(1)
    plt.plot(dates,
             cl,
             linewidth=2,
             color='red',
             path_effects=[
                 path_effects.SimpleLineShadow(),
                 path_effects.Normal(offset=(0.0, 5.0))
             ])
    ax = plt.subplot(1, 1, 1)
    ax.scatter(dates, cl)
    ax.plot(dates, cl, "or")
    plt.xlabel("Date (Month)")
    plt.ylabel("Value ($)")
    plt.title("Daily Closing Values")
    plt.show()
def LollipopPlot(Fig, Time, Data, Regression):

    cTime = Time
    cData = Data
    cRegression = Regression

    ax = Fig.gca()

    (markers, stemlines, baseline) = ax.stem(cTime,
                                             cData,
                                             bottom=-0.4,
                                             label='Data',
                                             basefmt=" ")
    plt.setp(stemlines, linestyle="-", color="red", linewidth=0.5, alpha=0.5)
    plt.setp(markers, color="red", alpha=0.75)

    ax.plot(cTime,
            cRegression,
            'b-',
            label='Model',
            path_effects=[
                path_effects.SimpleLineShadow(alpha=0.2, rho=0.2),
                path_effects.Normal()
            ])

    ax.set_ylabel('Temperature', fontsize=16, fontweight='bold')
    ax.set_xlabel('Time', fontsize=16, fontweight='bold')
    ax.legend(loc=0, fontsize=14)
    ax.set_ylim(-0.4, 110)
    PlotStyle(ax, '')
def test_patheffect3():
    p1, = plt.plot([1, 3, 5, 4, 3], 'o-b', lw=4)
    p1.set_path_effects([path_effects.SimpleLineShadow(),
                         path_effects.Normal()])
    plt.title(
        r'testing$^{123}$',
        path_effects=[path_effects.withStroke(linewidth=1, foreground="r")])
    leg = plt.legend([p1], [r'Line 1$^2$'], fancybox=True, loc='upper left')
    leg.legendPatch.set_path_effects([path_effects.withSimplePatchShadow()])

    text = plt.text(2, 3, 'Drop test', color='white',
                    bbox={'boxstyle': 'circle,pad=0.1', 'color': 'red'})
    pe = [path_effects.Stroke(linewidth=3.75, foreground='k'),
          path_effects.withSimplePatchShadow((6, -3), shadow_rgbFace='blue')]
    text.set_path_effects(pe)
    text.get_bbox_patch().set_path_effects(pe)

    pe = [path_effects.PathPatchEffect(offset=(4, -4), hatch='xxxx',
                                       facecolor='gray'),
          path_effects.PathPatchEffect(edgecolor='white', facecolor='black',
                                       lw=1.1)]

    t = plt.gcf().text(0.02, 0.1, 'Hatch shadow', fontsize=75, weight=1000,
                       va='center')
    t.set_path_effects(pe)
def draw_timed_sequence(data_list, title, data_range):
    # customize figure properties
    scr_dpi, style = 96, 'seaborn-white'
    mplt.figure(figsize=(800 / scr_dpi, 300 / scr_dpi), dpi=scr_dpi)
    mplt.style.use(style)

    # drow speed curves
    time_seq = [i[0] for i in data_list]
    data_seq = [i[1] for i in data_list]
    mplt.plot(time_seq, data_seq, marker='', color='mediumvioletred', \
                linewidth=3, alpha=1, \
                path_effects=[mpe.SimpleLineShadow(shadow_color='b'), mpe.Normal()])

    mplt.title(title, fontsize=10, fontweight=0, color='grey', loc='left')
    mplt.grid(True)

    # set x-axis properties
    xmajorLocator = MultipleLocator(2)
    xmajorFormatter = FormatStrFormatter('%1d')
    ax = mplt.gca()
    ax.xaxis.set_major_locator(xmajorLocator)
    ax.xaxis.set_major_formatter(xmajorFormatter)

    # set y-axis properties
    mplt.ylim(data_range)
def draw_speedometer(speedometer_record):
    # customize figure properties
    scr_dpi, style = 96, 'seaborn-white'
    mplt.figure(1, figsize=(1200 / scr_dpi, 300 / scr_dpi), dpi=scr_dpi)
    mplt.style.use(style)
    gs = gridspec.GridSpec(1, 2, width_ratios=[2, 1])
    mplt.subplot(gs[0])

    # drow speed curves
    time = [i[0] for i in speedometer_record]
    speed = [i[1] for i in speedometer_record]
    mplt.plot(time, speed, marker='', color='mediumvioletred', \
                linewidth=2, alpha=1, \
                path_effects=[mpe.SimpleLineShadow(shadow_color='b'), mpe.Normal()])
    # mplt.grid(True)
    # mplt.ylim((-2, 2))
    # mplt.legend(['sine'])
    mplt.title("Speed (Kmph)",
               fontsize=10,
               fontweight=0,
               color='grey',
               loc='left')
    # remove labels
    mplt.xlabel('Time (Second)')
    mplt.tick_params(labelbottom=True)
    #mplt.ylabel('Speed (Km/H)')
    mplt.tick_params(labelleft=True)
    return
Example #9
0
 def plot_edges(self, axis, E, shadow=True, **kw):
     kw['c'] = kw['c'] if 'c' in kw else 'black'
     kw['alpha'] = kw['alpha'] if 'alpha' in kw else 0.6
     kw['zorder'] = kw['zorder'] if 'zorder' in kw else 1
     if shadow:
         kw['path_effects'] = [pfx.SimpleLineShadow(), pfx.Normal()]
     list(map(lambda e: axis.plot(e[:, 0], e[:, 1], **kw), E))
Example #10
0
    def lines(self, latlons, color, shadow=False, **kwargs):
        if not latlons.any():
            return
        else:
            use_kw = kwargs
            ispoint = latlons.shape[0] == 1

            if ispoint:
                # a line plot will cause a singular point to vanish, so we force it to
                # plot points here
                use_kw = use_kw.copy()
                use_kw.pop('linestyle', None)
                size = use_kw.pop('linewidth', 2)
                use_kw['marker'] = 'o'
                use_kw['markersize'] = size
                use_kw['markeredgewidth'] = 0.0

            if shadow:
                shadow_kw = dict(offset=(0.5, -0.5), alpha=0.6)
                if ispoint:
                    shadow_effect = path_effects.SimplePatchShadow(**shadow_kw)
                else:
                    shadow_effect = path_effects.SimpleLineShadow(**shadow_kw)

                use_kw['path_effects'] = [shadow_effect, path_effects.Normal()]

            self._bgmap.ax.plot(latlons[:, 1], latlons[:, 0],
                                color=color, transform=ccrs.PlateCarree(), **use_kw)
Example #11
0
def send_pie(bot, update, data):
    colors = ['yellowgreen', 'lightskyblue', 'gold', 'lightcoral', 'seagreen', 'lightsteelblue', 'lightpink']
    explode = [0.01 for _ in range(7)]
    print(data)
    fig = plt.figure(figsize=[10, 10])
    ax = fig.add_subplot(111)
    plt.axis('off')
    plt.title("Статистика по представителям 7 классов интеллекта")
    patches, text, auto_texts = ax.pie(data.values(),
                                       colors=colors,
                                       explode=explode,
                                       # labels=a.keys(),
                                       autopct='%1.1f%%',
                                       startangle=90,
                                       radius=0.4,
                                       wedgeprops={"linewidth": 6, },
                                       shadow=True,
                                       center=(0.5, 0.5),
                                       frame=True,
                                       pctdistance=1.125,
                                       )

    for patch in patches:
        patch.set_path_effects([path_effects.SimpleLineShadow(),
                                path_effects.Normal()])
    user_id = str(update.effective_user.id)
    plt.legend(data.keys())
    plt.savefig(user_id + ".png")
    bot.send_photo(chat_id=user_id, photo=open(user_id + ".png", 'rb'))
    os.remove(user_id + ".png")
Example #12
0
def plotOpen(dates, op):
    """

    produces a graph of the open values for each day over 3 months.

    Arguments:
        dates: Datetime object list representing stock dates
        op: List of floats representing open values for each date


    """
    plt.plot(dates,
             op,
             linewidth=2,
             color='red',
             path_effects=[
                 path_effects.SimpleLineShadow(),
                 path_effects.Normal(offset=(0.0, 5.0))
             ])
    ax = plt.subplot(1, 1, 1)
    ax.scatter(dates, op)
    ax.plot(dates, op, "or")
    plt.xlabel("Date (Month)")
    plt.ylabel("Value ($)")
    plt.title("Daily Open Values")
    plt.show()
Example #13
0
 def updateCanvas(self):
     self.ax.clear()
     self.ax.set_facecolor('#828282')
     self.ax.set_ylabel("Numbers inserted", family='sans-serif', size="13", weight="bold")
     self.ax.set_xlabel("Time", family='sans-serif', size="13", weight="bold")
     self.ax.set_title("Match stats", family='sans-serif', size="15", weight="bold")
     self.ax.step(list(map(lambda x: x[0], self.moves)), list(map(lambda x: x[1], self.moves)), color="white", linewidth=5.0, 
     path_effects=[path_effects.SimpleLineShadow(shadow_color="white"),
     path_effects.Normal()])
     self.ax.figure.canvas.draw()
Example #14
0
def plot_xmoc_tseries(time,
                      moc_t,
                      which_lat=['max'],
                      which_moc='amoc',
                      str_descript='',
                      str_time='',
                      figsize=[]):
    import matplotlib.patheffects as path_effects
    from matplotlib.ticker import AutoMinorLocator

    if len(figsize) == 0: figsize = [13, 4]
    fig, ax = plt.figure(figsize=figsize), plt.gca()

    for ii in range(len(which_lat)):
        if which_lat[ii] == 'max':
            str_label = 'max {:s}: 30°N<=lat<=45°N'.format(
                which_moc.upper(), which_lat[ii])
        else:
            str_label = 'max {:s} at: {:2.1f}°N'.format(
                which_moc.upper(), which_lat[ii])
        hp=ax.plot(time,moc_t[:,ii],\
                   linewidth=2,label=str_label,marker='o',markerfacecolor='w',\
                   path_effects=[path_effects.SimpleLineShadow(offset=(1.5,-1.5),alpha=0.3),path_effects.Normal()])
        # plot mean value with trinagle
        plt.plot(time[0]-(time[-1]-time[0])*0.015,moc_t[:,ii].mean(),\
                 marker='<',markersize=8,markeredgecolor='k',markeredgewidth=0.5,\
                 color=hp[0].get_color(),zorder=3,clip_box=False,clip_on=False)

        # plot std. range
        plt.plot(time[0]-(time[-1]-time[0])*0.015,moc_t[:,ii].mean()+moc_t[:,ii].std(),\
                 marker='^',markersize=6,markeredgecolor='k',markeredgewidth=0.5,\
                 color=hp[0].get_color(),zorder=3,clip_box=False,clip_on=False)

        plt.plot(time[0]-(time[-1]-time[0])*0.015,moc_t[:,ii].mean()-moc_t[:,ii].std(),\
                 marker='v',markersize=6,markeredgecolor='k',markeredgewidth=0.5,\
                 color=hp[0].get_color(),zorder=3,clip_box=False,clip_on=False)

    ax.legend(loc='lower right',
              shadow=True,
              fancybox=True,
              frameon=True,
              mode='None')
    ax.set_xlabel('Time [years]', fontsize=12)
    ax.set_ylabel('{:s} in [Sv]'.format(which_moc.upper()), fontsize=12)
    minor_locator = AutoMinorLocator(5)
    ax.yaxis.set_minor_locator(AutoMinorLocator(4))
    ax.xaxis.set_minor_locator(minor_locator)
    plt.grid(which='major')
    plt.xticks(np.arange(1940, 2015, 5))
    plt.xlim(time[0] - (time[-1] - time[0]) * 0.015,
             time[-1] + (time[-1] - time[0]) * 0.015)
    plt.show(block=False)

    fig.canvas.draw()
    return (fig, ax)
Example #15
0
 def plot_edge(self, axis, s, shadow=True, **kw):
     p = self.data[list(s)]
     if 'color' in kw:
         kw['c'] = kw['color']
         del kw['color']
     kw['c'] = 'black' if not 'c' in kw else kw['c']
     kw['alpha'] = 0.5 if not 'alpha' in kw else kw['alpha']
     kw['zorder'] = 1 if not 'zorder' in kw else kw['zorder']
     kw = {'color' : 'black', 'alpha' : 0.5, 'zorder' : 1}
     if shadow:
         kw['path_effects'] = [pfx.SimpleLineShadow(), pfx.Normal()]
     return axis.plot(p[:,0], p[:,1], **kw)
Example #16
0
def single_plot(robot,
                p,
                fig,
                link_plot,
                joint_plot,
                eff_plot,
                cfg_path_plots=None,
                path_history=None,
                save_dir=None,
                ax=None):
    from copy import copy
    from matplotlib.lines import Line2D
    points_traj = robot.fkine(p)
    points_traj = torch.cat([torch.zeros(len(p), 1, 2), points_traj], dim=1)
    traj_alpha = 0.3
    ends_alpha = 0.5

    lw = link_plot.get_lw()
    link_traj = [
        ax.plot(points[:, 0],
                points[:, 1],
                color='gray',
                alpha=traj_alpha,
                lw=lw,
                solid_capstyle='round')[0] for points in points_traj
    ]
    joint_traj = [
        ax.plot(points[:-1, 0],
                points[:-1, 1],
                'o',
                color='tab:red',
                alpha=traj_alpha,
                markersize=lw)[0] for points in points_traj
    ]
    eff_traj = [
        ax.plot(points[-1:, 0],
                points[-1:, 1],
                'o',
                color='black',
                alpha=traj_alpha,
                markersize=lw)[0] for points in points_traj
    ]

    for i in [0, -1]:
        link_traj[i].set_alpha(ends_alpha)
        link_traj[i].set_path_effects(
            [path_effects.SimpleLineShadow(),
             path_effects.Normal()])
        joint_traj[i].set_alpha(ends_alpha)
        eff_traj[i].set_alpha(ends_alpha)
    link_traj[0].set_color('green')
    link_traj[-1].set_color('orange')
Example #17
0
def draw_scale_bar(ax,
                   X_bar=200,
                   Y_bar=150,
                   y_text=100,
                   scale=5 * u.arcmin,
                   pixel_scale=2.5,
                   lw=6,
                   fontsize=15,
                   color='w',
                   format='.1f',
                   border_color='k',
                   border_lw=0.5,
                   alpha=1):
    """ Draw a scale bar """
    import matplotlib.patheffects as PathEffects
    L_bar = scale.to(u.arcsec).value / pixel_scale

    ax.plot(
        [X_bar - L_bar / 2, X_bar + L_bar / 2], [Y_bar, Y_bar],
        color=color,
        alpha=alpha,
        lw=lw,
        path_effects=[PathEffects.SimpleLineShadow(),
                      PathEffects.Normal()])

    ax.text(X_bar,
            y_text,
            '{0:{1}} {2}'.format(scale.value, format, scale.unit),
            color=color,
            alpha=alpha,
            fontsize=fontsize,
            ha='center',
            va='center',
            fontweight='bold',
            path_effects=[
                PathEffects.SimpleLineShadow(),
                PathEffects.withStroke(linewidth=border_lw,
                                       foreground=border_color)
            ])
Example #18
0
def plot_residuals(figure, time, signal, fit_solution, residuals, noise):
    cFig = figure
    gridSp = GridSpec(2, 2)

    ax1 = cFig.add_subplot(gridSp[:, 0])
    ax2 = cFig.add_subplot(gridSp[0, 1])
    ax3 = cFig.add_subplot(gridSp[1, 1])

    ax1.plot(time, signal, 'ro', label='Data')
    ax1.plot(time, fit_solution, label='Regression', path_effects=[path_effects.SimpleLineShadow(alpha=0.2, rho=0.2),
                                                                  path_effects.Normal()])
    ax1.legend(loc=0)
    util.plot_style(ax1, 'Fitted Model')

    ax2.plot(residuals, path_effects=[path_effects.SimpleLineShadow(alpha=0.2, rho=0.2),
                                      path_effects.Normal()])
    util.plot_style(ax2, 'Residuals')

    ax3.plot(noise, path_effects=[path_effects.SimpleLineShadow(alpha=0.2, rho=0.2),
                                  path_effects.Normal()])
    util.plot_style(ax3, 'Noise')

    plt.tight_layout()
Example #19
0
def plotValues(dates, vals, col_name, ticker):
    plt.figure(1)
    plt.plot(dates,
             vals,
             linewidth=2,
             color='red',
             path_effects=[
                 path_effects.SimpleLineShadow(),
                 path_effects.Normal(offset=(0.0, 5.0))
             ])

    plt.xlabel("Date (Month)")
    plt.ylabel("Value ($)")
    title = str("Daily " + col_name.capitalize() + " Values (" + ticker + ")")
    plt.title(title)
    plt.show()
Example #20
0
def draw(series, name, active):

    plt.rcParams['figure.figsize'] = (4, 2.5)  # 设置figure_size尺寸
    plt.rcParams['axes.facecolor'] = 'FFAE00' if active else '282C35'

    plt.xticks([])
    plt.yticks([])
    plt.axis('off')
    pd.Series(series).plot(
        linewidth='3',
        color=('#ffffff' if active else '#FFAE00'),
        path_effects=[path_effects.SimpleLineShadow(),
                      path_effects.Normal()])
    plt.savefig(path + name + ".png",
                bbox_inches='tight',
                facecolor=('#FFAE00' if active else '#282C35'))
    plt.clf()
Example #21
0
    def __init__(self, ax, orbit_collection, calval=True):

        # Prepare Input
        orbit_ensemble = orbit_collection.orbit_ensemble
        orbit_ensemble_mean = orbit_ensemble.get_ensemble_mean()
        calval_ensemble = orbit_collection.calval_ensemble

        # Plot all datasets
        for dataset_id in orbit_ensemble.dataset_ids:

            color = DATASET_COLOR[dataset_id]
            marker = DATASET_MARKER[dataset_id]

            # Get statistics for each dataset
            dataset_mean = orbit_ensemble.get_member_mean(dataset_id)

            ax.scatter(orbit_ensemble.time,
                       dataset_mean - orbit_ensemble_mean,
                       color=color,
                       marker=marker,
                       **self.datasets_props)

        # Plot the calval ensembles
        if calval:
            calval_props = dict(aem=self.calval_props_aem,
                                oib=self.calval_props_oib)
            shadow = [
                path_effects.SimpleLineShadow(offset=(1, -1)),
                path_effects.Normal()
            ]
            for calval_id in calval_ensemble.dataset_ids:
                source_id = calval_id[-3:]
                dataset_mean = calval_ensemble.get_member_mean(calval_id)
                ax.scatter(calval_ensemble.time,
                           dataset_mean - orbit_ensemble_mean,
                           path_effects=shadow,
                           **calval_props[source_id])

        ax.axhline(0, **self.zero_line_props)
        ax.set_ylim(-2, 2)
        ax.set_xlim(orbit_collection.time_range)
Example #22
0
def single_plot(robot, p, fig, link_plot, joint_plot, eff_plot, cfg_path_plots=None, path_history=None, save_dir=None, ax=None):
    from copy import copy
    from matplotlib.lines import Line2D
    points_traj = robot.fkine(p)
    points_traj = torch.cat([torch.zeros(len(p), 1, 2, dtype=points_traj.dtype), points_traj], dim=1)
    traj_alpha = 0.3
    ends_alpha = 0.5
    
    lw = link_plot.get_lw()
    link_traj = [ax.plot(points[:, 0], points[:, 1], color='gray', alpha=traj_alpha, lw=lw, solid_capstyle='round')[0] for points in points_traj]
    joint_traj = [ax.plot(points[:-1, 0], points[:-1, 1], 'o', color='tab:red', alpha=traj_alpha, markersize=lw)[0] for points in points_traj]
    eff_traj = [ax.plot(points[-1:, 0], points[-1:, 1], 'o', color='black', alpha=traj_alpha, markersize=lw)[0] for points in points_traj]
    # for link_plot, joint_plot, eff_plot, points in zip(link_traj, joint_traj, eff_traj, points_traj):
    #     link_plot.set_data(points[:, 0], points[:, 1])
    #     joint_plot.set_data(points[:-1, 0], points[:-1, 1])
    #     eff_plot.set_data(points[-1:, 0], points[-1:, 1])
    for i in [0, -1]:
        link_traj[i].set_alpha(ends_alpha)
        link_traj[i].set_path_effects([path_effects.SimpleLineShadow(), path_effects.Normal()])
        joint_traj[i].set_alpha(ends_alpha)
        eff_traj[i].set_alpha(ends_alpha)
    link_traj[0].set_color('green')
    link_traj[-1].set_color('orange')
    # ax.add_artist(link_traj[2])

    # def divide(p): # divide the path into several segments that obeys the wrapping around rule [TODO]
    #     diff = torch.abs(p[:-1]-p[1:])
    #     div_idx = torch.where(diff.max(1) > np.pi)
    #     div_idx = torch.cat([-1, div_idx])
    #     segments = []
    #     for i in range(len(div_idx)-1):
    #         segments.append(p[div_idx[i]+1:div_idx[i+1]+1])
    #     segments.append(p[div_idx[-1]+1:])
    #     for i in range(len(segments)-1):
    #         if torch.sum(torch.abs(segments[i]) > np.pi) == 2:


    for cfg_path in cfg_path_plots:
        cfg_path.set_data(p[:, 0], p[:, 1])
Example #23
0
def make_chart(data, filename):
    #this function creates a chart from a dataframe
    df = data
    print("generating matplotlib chart")
    plt.style.use('bmh')
    plt.figure(figsize=(20,15))
    x = ['1 month', '2 month', '3 month', '6 month', '1 year', '2 year', '3 year', '5 year', '7 year', '10 year', '20 year', '30 year']
    y1 = list(df.iloc[-1][2:])
    y2 = list(df.iloc[-2][2:])
    y3 = list(df.iloc[-3][2:])
    plt.plot(x, y1, 'gs-', label = df.iloc[-1][1],markersize=8, linewidth=3.0, path_effects=[path_effects.SimpleLineShadow(shadow_color="green", linewidth=5),path_effects.Normal()])
    plt.plot(x, y2, '^-' ,color='red', label = df.iloc[-2][1], markersize=6, path_effects=[path_effects.SimpleLineShadow(shadow_color="red", linewidth=5),path_effects.Normal()])
    plt.plot(x, y3, 'bo-' , label = df.iloc[-3][1], markersize=4, path_effects=[path_effects.SimpleLineShadow(shadow_color="blue", linewidth=5),path_effects.Normal()])
    plt.title('Treasury Yield Curve')
    plt.xlabel('Maturity')
    plt.ylabel('Interest Rates')
    plt.title('Daily US Treasury Yield Curve')
    plt.legend(loc='upper left')
    plt.grid(False)

    #saving chart in a file with the date when it was created
    plt.savefig(f'charts/{filename}.png')
    print("completed")
    plt.show()
Example #24
0
    cID=Identifier
    cDir=UniprotDir+'\\'+cID+'.txt'
    
    cLines=GetFileLines(cDir)  #Load the data 
    nLines=len(cLines)
    
    SeqLoc=[j for j in range(nLines) if re.match('(.*)'+'SEQUENCE'+'(.*)',cLines[j])] #Find the location of the SEQUENCE pattern 
    SeqLine=cLines[SeqLoc[-1]].split()
    
    return int(SeqLine[2])

#   
ProteinSizes=[GetSize(val) for val in TargetList]

plt.figure(1,figsize=(7,7))
plt.plot(ProteinSizes,path_effects=[path_effects.SimpleLineShadow(alpha=0.2,rho=0.2),
                       path_effects.Normal()])

ax=plt.gca()

PlotStyle(ax,'Protein Sequence Lenght')

###############################################################################
#                          Pattern mathching functions   
###############################################################################

#Iterates through an uniprot file and a term list 
def FileIterator(File,TermList):
    
    cF=GetFileLines(File)
    nLines=len(cF)
Example #25
0
import matplotlib.pyplot as plt
import matplotlib.patheffects as path_effects

fig = plt.figure(figsize=(5, 1.5))
text = fig.text(0.5,
                0.5, 'Hello path effects world!\nThis is the normal '
                'path effect.\nPretty dull, huh?',
                ha='center',
                va='center',
                size=20)
text.set_path_effects([path_effects.Normal()])
plt.show()

text = plt.text(0.5,
                0.5,
                'Hello path effects world!',
                path_effects=[path_effects.withSimplePatchShadow()])

plt.plot([0, 3, 2, 5],
         linewidth=5,
         color='blue',
         path_effects=[path_effects.SimpleLineShadow(),
                       path_effects.Normal()])
plt.show()
Example #26
0
    def plot_spectrum_heatmap(self,
                              plot_spec1=True,
                              frange=[],
                              title="Audio Comparison",
                              cmap="plasma",
                              background_color="white",
                              background_alpha=0.5):
        """
        Plots a heatmap and spectrogram showing the relative hot and cool spots of thw two compared AudioAnalyzer class instances. 
        A number of options are available to customize the appearance of the generated plot. 
        """

        #       DATAFRAME SETUP
        if plot_spec1:
            df = self.original_df
        else:
            df = self.modified_df

        df['ratio_amplitude'] = self.ratio_df.scaled_amplitude

        df['attenuated_scaled'] = df.scaled_amplitude
        df['boosted_scaled'] = df.scaled_amplitude

        if len(frange):
            plot_df = df.loc[(df.bins >= frange[0] / 1000)
                             & (df.bins <= frange[1] / 1000)]
            ratio_df = self.ratio_df.loc[
                (self.ratio_df.bins >= frange[0] / 1000)
                & (self.ratio_df.bins <= frange[1] / 1000)]
        else:
            plot_df = df
            ratio_df = self.ratio_df

#       FIGURE SETUP
        fig = plt.figure(figsize=(20, 10))
        ax1 = fig.add_subplot(211, facecolor="white")
        # ax1 = plt.subplot2grid((8,1), (0,0), rowspan=5, facecolor="white", fig=fig)
        ax2 = fig.add_subplot(211, facecolor="#00000000")
        # ax2 = plt.subplot2grid((8,1), (0,0), rowspan=2, facecolor="#00000000", fig=fig)
        # fig2 = plt.figure(figsize=(32, 8))
        # cbaxes = fig2.add_subplot(32,1,1)
        cbaxes = plt.subplot2grid((16, 1), (10, 0))
        cbaxes.set_title("Scaled Amplitude Ratio", size=14)

        #       HEATMAP PLOT
        sns.heatmap(data=ratio_df.set_index('bins').transpose(),
                    cbar=True,
                    cbar_ax=cbaxes,
                    cbar_kws={"orientation": "horizontal"},
                    cmap=cmap,
                    alpha=0.95,
                    zorder=1,
                    ax=ax1,
                    vmin=0.0,
                    vmax=1.0)
        ax1.set_xlabel("")
        ax1.set_xticks([])
        ax1.set_ylabel("")
        ax1.set_yticks([])

        #       FREQUENCY PLOT
        sns.lineplot(data=plot_df,
                     x="bins",
                     y="scaled_amplitude",
                     color='black',
                     zorder=10,
                     ax=ax2,
                     path_effects=[
                         path_effects.SimpleLineShadow(),
                         path_effects.Normal()
                     ])
        ax2.fill_between(x=plot_df.bins,
                         y1=plot_df.scaled_amplitude,
                         color='white',
                         alpha=0.0)
        ax2.fill_between(x=plot_df.bins,
                         y1=plot_df.scaled_amplitude,
                         y2=1.0,
                         color=background_color,
                         alpha=background_alpha)

        ax2.set_xlabel("Frequency (kHz)", size=28)
        ax2.set_ylabel("Scaled Amplitude", size=28)

        ax2.margins(0)
        fig.suptitle(title, size=36, y=0.95)

        fig.savefig(title)
def create_plots(robot, obstacles, cfg=None):
    from matplotlib.cm import get_cmap
    cmaps = [get_cmap('Reds'), get_cmap('Blues')]
    plt.rcParams.update({
        "text.usetex": True,
        "font.family": "sans-serif",
        "font.sans-serif": ["Helvetica"]
    })

    fig = plt.figure(figsize=(3, 3))
    ax = fig.add_subplot(111)  #, projection='3d'

    # Plot ostacles
    # ax.axis('tight')
    ax.set_xlim(-8, 8)
    ax.set_ylim(-8, 8)
    ax.set_aspect('equal', adjustable='box')
    ax.set_xticks([-4, 0, 4])
    ax.set_yticks([-4, 0, 4])
    for obs in obstacles:
        cat = obs[3] if len(obs) >= 4 else 1
        # print('{}, cat {}, {}'.format(obs[0], cat, obs))
        if obs[0] == 'circle':
            ax.add_patch(Circle(obs[1], obs[2], color=cmaps[cat](
                0.5)))  #path_effects=[path_effects.withSimplePatchShadow()],
        elif obs[0] == 'rect':
            ax.add_patch(
                Rectangle((obs[1][0] - float(obs[2][0]) / 2,
                           obs[1][1] - float(obs[2][1]) / 2),
                          obs[2][0],
                          obs[2][1],
                          color=cmaps[cat](0.5))
            )  #, path_effects=[path_effects.withSimplePatchShadow()]

    # Plot robot
    if cfg is None:
        cfg = torch.rand(1, robot.dof, dtype=torch.float32)
        cfg = cfg * (robot.limits[:, 1] - robot.limits[:, 0]) + robot.limits[:,
                                                                             0]
    points = robot.fkine(cfg)[0]
    points = torch.cat([torch.zeros(1, points.shape[1]), points], dim=0)
    trans = ax.transData.transform
    lw = ((trans((1, robot.link_width)) - trans(
        (0, 0))) * 72 / ax.figure.dpi)[1]
    link_plot, = ax.plot(
        points[:, 0],
        points[:, 1],
        color='silver',
        lw=lw,
        solid_capstyle='round',
        path_effects=[path_effects.SimpleLineShadow(),
                      path_effects.Normal()])
    joint_plot, = ax.plot(points[:-1, 0],
                          points[:-1, 1],
                          'o',
                          color='tab:red',
                          markersize=lw)
    eff_plot, = ax.plot(points[-1:, 0],
                        points[-1:, 1],
                        'o',
                        color='black',
                        markersize=lw)
Example #28
0
def drawFunicular(x, y, CapLam=0.1, M=2, drawArrows=False):
    pSize = 2.009
    goldRat = 1.618
    lineWidth = 1
    pathEffects = [path_effects.SimpleLineShadow(), path_effects.Normal()]
    fig = plt.figure(figsize=(pSize * goldRat, pSize))
    ax = fig.gca()
    fig.subplots_adjust(left=0.1, right=1.0 - 0.1, bottom=0.24, top=0.99)
    rx = 0.05
    ry = rx
    shifty = 0.75 / goldRat
    cvb_bot = np.zeros((90, 2))
    cvb_bot[:, 0] = np.linspace(calc_lam(CapLam, 1, numsys=2), 1.0 - rx, 90)
    cvb_bot[:, 1] = np.ones(90) * shifty
    cvb_top = np.zeros((90, 2))
    cvb_top[:, 0] = np.linspace(calc_lam(CapLam, 0, numsys=2), 1.0 - rx, 90)
    cvb_top[:, 1] = np.ones(90) * (shifty + 2.0 * ry)
    lamVals = x - x.min()
    lamVals /= lamVals.max()
    gVals = y - y.min()
    gVals /= (2.0 * gVals.max() * goldRat)
    ax.plot(lamVals[2:], gVals[2:], 'k', lw=lineWidth)

    l = CapLam
    numsys = M
    rotation = []
    y = []
    for i in range(M):
        if calc_lam(CapLam, i, numsys=M) > rx and calc_lam(
                CapLam, i, numsys=M) < (1.0 - rx):
            rotation.append(45)
            y.append(1.0)
        elif calc_lam(CapLam, i, numsys=M) < rx:
            alpha = np.arcsin((rx - calc_lam(CapLam, i, numsys=M)) / rx)
            rotation.append(45 - alpha / np.pi * 180.0)
            y.append(np.cos(alpha))
        else:
            alpha = np.arcsin((rx - (1 - calc_lam(CapLam, i, numsys=M))) / rx)
            rotation.append(45 - alpha / np.pi * 180.0)
            y.append(np.cos(alpha))
    shiftMarker = 0.02 * np.sqrt(2)

    ax.plot(cvb_bot[:, 0], cvb_bot[:, 1], 'k', lw=lineWidth, zorder=1)
    ax.plot(cvb_top[:, 0], cvb_top[:, 1], 'k', lw=lineWidth, zorder=1)
    #    ax.add_artist(patches.Arc((rx,shifty+ry), 2*rx, 2*ry, theta1=90, theta2=270, lw=lineWidth))
    ax.add_artist(
        patches.Arc((1.0 - rx, shifty + ry),
                    2 * rx,
                    2 * ry,
                    theta1=270,
                    theta2=90,
                    lw=lineWidth))
    #    ax.add_artist(patches.Arc((rx,shifty+ry), 1.4*rx, 1.4*ry, lw=lineWidth))
    ax.add_artist(
        patches.Arc((1.0 - rx, shifty + ry), 1.4 * rx, 1.4 * ry, lw=lineWidth))
    # ax.annotate(r'$\Lambda=0$', xy=(-0.01, shifty+ry), xytext=(-0.05, shifty+ry), va='center', ha='right', arrowprops=dict(arrowstyle='-'))
    # ax.annotate(r'$\Lambda=\frac{\pi}{2}$', xy=(0.5,  shifty+2*ry+0.01), xytext=(0.5, shifty+2*ry+0.05), va='bottom', ha='center', arrowprops=dict(arrowstyle='-'))
    # ax.annotate(r'$\Lambda=\frac{3\pi}{2}$', xy=(0.5,  shifty-0.01), xytext=(0.5, shifty-0.05), va='top', ha='center', arrowprops=dict(arrowstyle='-'))
    # ax.annotate(r'$\Lambda=\pi$', xy=(1.01,  shifty+ry), xytext=(1.05, shifty+ry), va='center', ha='left', arrowprops=dict(arrowstyle='-'))
    # if np.fabs(rotation[0]-45)>0.0001:
    #     print(alpha)
    #     ax.annotate('Current state:\n$\Lambda={:.1f}$'.format(CapLam), xy=(calc_lam(CapLam, 0, numsys=M), shifty+ry+np.cos(alpha)*ry),
    #         xytext=(calc_lam(CapLam, 0, numsys=M)-np.sin(alpha)*1.5*rx, shifty+(1+np.cos(alpha)*2.5)*ry),
    #         arrowprops=dict(arrowstyle='<-', linewidth=3), va='center', ha='center', zorder=0)
    # else:
    #     ax.annotate('Current state:\n$\Lambda={:.1f}$'.format(CapLam), xy=(calc_lam(CapLam, 0, numsys=M), shifty+2.0*ry+shiftMarker),
    #         xytext=(calc_lam(CapLam, 0, numsys=M), shifty+3.5*ry),
    #         arrowprops=dict(arrowstyle='<-', linewidth=3), va='center', ha='center', zorder=0)
    #arrows in the conveyor belt
    #    drawCirc(ax,rx*0.8,rx,shifty+ry,45,270, color_='red')
    drawCirc(ax,
             rx * 0.8,
             1.0 - rx,
             shifty + ry,
             225,
             270,
             lineWidth=lineWidth,
             color_='red')

    for i in range(int(M / 2)):
        x = calc_lam(CapLam, i, numsys=M) - np.sqrt(1 - y[i]**2) * shiftMarker
        ax.add_patch(  #Create triangle as arrow head
            patches.RegularPolygon(
                (x, shifty + ry + y[i] * ry),  # (x,y)
                4,  # number of vertices
                0.02,  # radius
                rotation[i] / 180.0 * np.pi,  # orientation
                color='red',
                zorder=10))
        ax.scatter(x,
                   gVals[np.abs(lamVals - x).argmin()] + shiftMarker,
                   s=30,
                   marker='o',
                   edgecolors='face',
                   color='r',
                   zorder=10)
        if drawArrows:
            ax.annotate('',
                        xy=(x,
                            gVals[np.abs(lamVals - x).argmin()] + shiftMarker),
                        xytext=(x + 0.1,
                                gVals[np.abs(lamVals - x - 0.1).argmin()] +
                                shiftMarker),
                        arrowprops=dict(arrowstyle='<-', linewidth=lineWidth))
        ax.plot([x, x],
                [gVals[np.abs(lamVals - x).argmin()], shifty + ry + y[i] * ry],
                color='0.8',
                lw=lineWidth,
                zorder=0)
    for i in range(int(M / 2)):
        x = calc_lam(CapLam, i + int(M / 2),
                     numsys=M) - np.sqrt(1 - y[i]**2) * shiftMarker
        ax.add_patch(  #Create triangle as arrow head
            patches.RegularPolygon(
                (x, shifty),  # (x,y)
                4,  # number of vertices
                0.02,  # radius
                rotation[i] / 180.0 * np.pi,  # orientation
                color='red',
                zorder=10))
        ax.plot(
            [x, x],
            [gVals[np.abs(lamVals - x).argmin()], shifty + (1.0 - y[i]) * ry],
            color='0.8',
            lw=lineWidth,
            zorder=0)
        ax.scatter(x,
                   gVals[np.abs(lamVals - x).argmin()] + shiftMarker,
                   s=30,
                   marker='o',
                   edgecolors='face',
                   color='r',
                   zorder=10)
        if drawArrows:
            ax.annotate('',
                        xy=(x,
                            gVals[np.abs(lamVals - x).argmin()] + shiftMarker),
                        xytext=(x - 0.1,
                                gVals[np.abs(lamVals - x + 0.1).argmin()] +
                                shiftMarker),
                        arrowprops=dict(arrowstyle='<-', linewidth=lineWidth))

    ax.set_xlim(-0.1, 1.1)
    ax.set_ylim(0, 1.2 / goldRat)
    ax.set_xticks([0.0, 0.5, 1.0])
    ax.set_xticklabels(['0\n(A)', r'$\sfrac{1}{2}$', '1\n(B)'])
    #    ax.text(lamVals[-1], gVals[-1]-0.05, 'Free energy profile', ha='right', va='top')
    ax.xaxis.set_ticks_position('bottom')
    ax.yaxis.set_ticks_position('left')
    ax.set_yticks([])
    ax.spines['left'].set_color('None')
    ax.spines['bottom'].set_smart_bounds(True)
    ax.spines['right'].set_color('None')
    ax.spines['top'].set_color('None')

    yarrow = ax.annotate('',
                         xy=(0, 0),
                         xytext=(0, 0.5 / goldRat),
                         ha='center',
                         va='bottom',
                         arrowprops=dict(arrowstyle='<|-',
                                         facecolor='k',
                                         linewidth=1.5))
    ax.text(-0.025,
            0.25 / goldRat,
            '$G(\lambda)$',
            ha='right',
            va='center',
            fontsize=14)
    ax.text(1.025, 0.0, '$\lambda$', ha='left', va='center', fontsize=14)
    return fig
Example #29
0
def updateEnsembler(x, y, ax, CapLam=0.1, M=8, drawArrows=False):
    pSize = 6.027
    goldRat = 1.70
    lineWidth = 1
    pathEffects = [path_effects.SimpleLineShadow(), path_effects.Normal()]

    rx = 0.05
    ry = rx
    shifty = 0.75 / goldRat
    cvb_bot = np.zeros((90, 2))
    cvb_bot[:, 0] = np.linspace(rx, 1.0 - rx, 90)
    cvb_bot[:, 1] = np.ones(90) * shifty
    cvb_top = np.zeros((90, 2))
    cvb_top[:, 0] = np.linspace(rx, 1.0 - rx, 90)
    cvb_top[:, 1] = np.ones(90) * (shifty + 2.0 * ry)
    lamVals = x - x.min()
    lamVals /= lamVals.max()
    gVals = y - y.min()
    gVals /= (2.0 * gVals.max() * goldRat)
    ax.plot(lamVals[2:], gVals[2:], 'k', lw=lineWidth)

    l = CapLam
    numsys = M
    rotation = []
    y = []
    #buildBox
    for i in range(M):
        if calc_lam(CapLam, i, numsys=M) > rx and calc_lam(
                CapLam, i, numsys=M) < (1.0 - rx):
            rotation.append(45)
            y.append(1.0)
        elif calc_lam(CapLam, i, numsys=M) < rx:
            alpha = np.arcsin((rx - calc_lam(CapLam, i, numsys=M)) / rx)
            if (CapLam + i * 2 * np.pi / float(M)) % (2. * np.pi) < np.pi:
                rotation.append(45 + alpha / np.pi * 180.0)
            else:
                rotation.append(45 - alpha / np.pi * 180.0)
            y.append(np.cos(alpha))
        else:
            alpha = np.arcsin((rx - (1 - calc_lam(CapLam, i, numsys=M))) / rx)
            if (CapLam + i * 2 * np.pi / float(M)) % (2. * np.pi) < np.pi:
                rotation.append(45 - alpha / np.pi * 180.0)
            else:
                rotation.append(45 + alpha / np.pi * 180.0)
            y.append(np.cos(alpha))
    shiftMarker = 0.02 * np.sqrt(2)

    #arrow
    if drawArrows:
        if np.fabs(rotation[0] - 45) > 0.0001:
            ax.annotate(
                'Current state:\n$\Lambda={:.1f}$'.format(CapLam),
                xy=(calc_lam(CapLam, 0, numsys=M),
                    shifty + ry + np.cos(alpha) * (ry + shiftMarker)),
                xytext=(calc_lam(CapLam, 0, numsys=M) - np.sin(alpha) * 2 * rx,
                        shifty + (1 + np.cos(alpha) * 5) * ry),
                fontsize='small',
                arrowprops=dict(arrowstyle='<-', linewidth=1.0, shrinkA=0.0),
                va='top',
                ha='center',
                zorder=0,
                bbox=dict(pad=-.1, lw=0.0, color='None'))
        else:
            ax.annotate('Current state:\n$\Lambda={:.1f}$'.format(CapLam),
                        xy=(calc_lam(CapLam, 0, numsys=M),
                            shifty + 2.0 * ry + shiftMarker),
                        xytext=(calc_lam(CapLam, 0,
                                         numsys=M), shifty + 6 * ry),
                        arrowprops=dict(arrowstyle='<-',
                                        linewidth=1.0,
                                        shrinkA=0.0),
                        fontsize='small',
                        va='top',
                        ha='center',
                        zorder=0,
                        bbox=dict(pad=-.1, lw=0.0, color='None'))

    #arrows in the conveyor belt
    drawCirc(ax,
             rx * 0.8,
             rx,
             shifty + ry,
             45,
             270,
             lineWidth=1.0,
             color_='red')
    drawCirc(ax,
             rx * 0.8,
             1.0 - rx,
             shifty + ry,
             225,
             270,
             lineWidth=1.0,
             color_='red')

    #box arrow?
    for i in range(M):
        x = calc_lam(CapLam, i, numsys=M)
        if x < rx:
            rx -= np.sqrt(1 - y[i]**2) * shiftMarker
        elif x > 1 - rx:
            rx += np.sqrt(1 - y[i]**2) * shiftMarker
        if (CapLam + i * 2 * np.pi / float(M)) % (2. * np.pi) < np.pi:
            ax.add_patch(  #Create triangle as arrow head
                patches.RegularPolygon(
                    (x, shifty + ry + y[i] * ry + y[i] * shiftMarker),  # (x,y)
                    4,  # number of vertices
                    0.02,  # radius
                    rotation[i] / 180.0 * np.pi,  # orientation
                    color='red',
                    zorder=10))
            ax.scatter(x,
                       gVals[np.abs(lamVals - x).argmin()] + shiftMarker,
                       s=30,
                       marker='o',
                       edgecolors='face',
                       color='r',
                       zorder=10)
            if drawArrows:
                ax.annotate('',
                            xy=(x, gVals[np.abs(lamVals - x).argmin()] +
                                shiftMarker),
                            xytext=(x + 0.1,
                                    gVals[np.abs(lamVals - x - 0.1).argmin()] +
                                    shiftMarker),
                            arrowprops=dict(arrowstyle='<-',
                                            linewidth=lineWidth))
            ax.plot([x, x], [
                gVals[np.abs(lamVals - x).argmin()],
                shifty + ry + y[i] * ry + y[i] * shiftMarker
            ],
                    color='0.8',
                    lw=lineWidth,
                    zorder=0)
        else:
            ax.add_patch(  #Create triangle as arrow head
                patches.RegularPolygon(
                    (x, shifty - y[i] * shiftMarker),  # (x,y)
                    4,  # number of vertices
                    0.02,  # radius
                    rotation[i] / 180.0 * np.pi,  # orientation
                    color='red',
                    zorder=10))
            ax.plot([x, x], [
                gVals[np.abs(lamVals - x).argmin()], shifty +
                (1.0 - y[i]) * ry - y[i] * shiftMarker
            ],
                    color='0.8',
                    lw=lineWidth,
                    zorder=0)
            ax.scatter(x,
                       gVals[np.abs(lamVals - x).argmin()] + shiftMarker,
                       s=30,
                       marker='o',
                       edgecolors='face',
                       color='r',
                       zorder=10)
            if drawArrows:
                ax.annotate('',
                            xy=(x, gVals[np.abs(lamVals - x).argmin()] +
                                shiftMarker),
                            xytext=(x - 0.1,
                                    gVals[np.abs(lamVals - x + 0.1).argmin()] +
                                    shiftMarker),
                            arrowprops=dict(arrowstyle='<-',
                                            linewidth=lineWidth))
         color='k',
         lw=2,
         path_effects=[pe.Stroke(linewidth=5, foreground='g'),
                       pe.Normal()])
# custom plot settings
plt.grid(True)
plt.ylim((-2, 2))
plt.legend(['sine'])
plt.savefig(
    r'D:\GoogleChromeDownloads\MyWebSites\100vragenKNS\toetskns.nl//sin1.png')
plt.show()

# In[32]:

# create line plot including an simple line shadow using path_effects
plt.plot(x,
         y,
         color='k',
         lw=2,
         path_effects=[pe.SimpleLineShadow(shadow_color='g'),
                       pe.Normal()])
# custom plot settings
plt.grid(True)
plt.ylim((-2, 2))
plt.legend(['sine'])
plt.savefig(
    r'D:\GoogleChromeDownloads\MyWebSites\100vragenKNS\toetskns.nl//sin2.png')
plt.show()

# In[ ]: