Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 10 Examples of "matplotlib in functional component" in Python

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'matplotlib' in functional components in Python. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

# Develop images
    sample_ya = model_a.process(sample_x).numpy()
    sample_yb = model_b.process(sample_x).numpy()

    if patch_size > 0:
        print('Cropping a {p}x{p} patch from the middle'.format(p=patch_size))
        xx = (sample_x.shape[2] - patch_size // 2) // 2
        yy = (sample_x.shape[1] - patch_size // 2) // 2
        sample_x = sample_x[:, yy:yy+patch_size, xx:xx+patch_size, :]
        sample_y = sample_y[:, 2*yy:2*(yy+patch_size), 2*xx:2*(xx+patch_size), :]
        sample_ya = sample_ya[:, 2*yy:2*(yy+patch_size), 2*xx:2*(xx+patch_size), :]
        sample_yb = sample_yb[:, 2*yy:2*(yy+patch_size), 2*xx:2*(xx+patch_size), :]

    # Plot images
    fig = imdiff.compare_ab_ref(sample_y, sample_ya, sample_yb, fig=plt.figure(), extras=extras)

    if output_dir is not None:
        from tikzplotlib import save as tikz_save
        dcomp = [x for x in fsutil.split(model_b_dirname) if re.match('(ln-.*|[0-9]{3})', x)]
        tikz_save('{}/examples_{}_{}_{}_{}.tex'.format(output_dir, camera, image, model_a_dirname, model_b_dirname), figureheight='8cm', figurewidth='8cm', strict=False)
    else:
        fig.tight_layout()
        fig.show(fig)

    fig.suptitle('{}, A={}, B={}'.format(image, model_a.model_code, model_b.model_code))
    plt.show()
    plt.close(fig)
# error line
            ax.plot([grid_dict[pre_ind] % X_GRID_NUM, grid_dict[tar_ind] % X_GRID_NUM],
                     [grid_dict[pre_ind] // X_GRID_NUM, grid_dict[tar_ind] // X_GRID_NUM], label='error line' if i == 0 else "", color='r', linewidth=0.5)
            # prediction point
            ax.scatter(grid_dict[pre_ind] % X_GRID_NUM, grid_dict[pre_ind] // X_GRID_NUM, label='prediction' if i == 0 else "", color='b', marker='.')
            # target point
            ax.scatter(grid_dict[tar_ind] % X_GRID_NUM, grid_dict[tar_ind] // X_GRID_NUM, label='target' if i == 0 else "", color='c', marker='.')

        ax.legend()
        # handles, labels = plt.gca().get_legend_handles_labels()
        # by_label = OrderedDict(zip(labels, handles))
        # plt.legend(by_label.values(), by_label.keys())

        plt.title("Errors of classification{}".format(suffix), y=1.08)
        plt.show()

        # save error line fig
        if baseline:
            fig.savefig('./graph_output/errors_visualization_1_1.png')  # calssification [200,200,200]
        else:
            fig.savefig('./graph_output/errors_visualization_1.png')  # classification [64,32,16]


    # output 2 values (regression)
    else:

        # 设置x,y主坐标轴
        my_x_ticks = np.arange(-40, 40, 10)
        my_y_ticks = np.arange(-30, 30, 10)
        ax.set_xticks(my_x_ticks, minor=False)
        ax.set_yticks(my_y_ticks, minor=False)
if pd.isnull(cf_at_time_max):
                    cf_at_time_max = cf[team][cf[team].Time == end].CumCF.max()
                if i == 0:
                    ax2.axvspan(start, end, ymin=cf_at_time_min / ymax,
                                ymax=cf_at_time_max / ymax, alpha=0.5, facecolor=colors_to_use[team],
                                label='{0:s} {1:s}'.format(team, pptype))
                else:
                    ax2.axvspan(start, end, ymin=cf_at_time_min / ymax,
                                ymax=cf_at_time_max / ymax, alpha=0.5, facecolor=colors[team])
                ax2.axvspan(start, end + 1, ymin=0, ymax=0.05, alpha=0.5, facecolor=colors_to_use[team])

    # Set limits
    ax2.set_xlim(0, cf[hname].Time.max())
    ax2.set_ylim(0, ymax)
    ax.set_ylabel('Cumulative CF')
    plt.legend(loc=2, framealpha=0.5, fontsize=8)

    # Ticks every 10 min on bottom axis; none on top axis
    ax.set_xlim(0, cf[hname].Time.max() / 60)
    ax.set_xticks(range(0, cf[hname].Time.max() // 60 + 1, 10))
    ax.set_xlabel('Time elapsed in game (min)')
    ax2.set_xticks([])

    # Set title
    plt.title(_get_corsi_timeline_title(season, game))

    plt.gcf().canvas.set_window_title('{0:d} {1:d} TL.png'.format(season, game))

    if save_file is None:
        plt.show()
    elif save_file == 'fig':
        return plt.gcf()
if nimages > ncol:
            nrow = nimages // ncol + 1
        else:
            nrow = 1
            ncol = nimages
        if figsize is None:
            figsize = (16, 16 // ncol * nrow)
        fig = plt.figure(figsize=figsize)

        for i in range(nimages):
            image = temp_tbl['Images']['Image'][i]
            label = temp_tbl['Images']['Label'][i]
            ax = fig.add_subplot(nrow, ncol, i + 1)
            ax.set_title('{}'.format(label))
            plt.imshow(image)
            plt.xticks([]), plt.yticks([])
"""Display the given set of images, optionally with titles.
    images: list or array of image tensors in HWC format.
    titles: optional. A list of titles to display with each image.
    cols: number of images per row
    cmap: Optional. Color map to use. For example, "Blues".
    norm: Optional. A Normalize instance to map values to colors.
    interpolation: Optional. Image interporlation to use for display.
    """
    titles = titles if titles is not None else [""] * len(images)
    rows = len(images) // cols + 1
    plt.figure(figsize=(14, 14 * rows // cols))
    i = 1
    for image, title in zip(images, titles):
        plt.subplot(rows, cols, i)
        plt.title(title, fontsize=9)
        plt.axis('off')
        plt.imshow(image.astype(np.uint8), cmap=cmap,
                   norm=norm, interpolation=interpolation)
        i += 1
    plt.show()
for (key, group) in grouped]
                min_key_diff = min([keys[_ + 1]-keys[_]
                                    for _ in xrange(len(keys)-1)])

                plt.boxplot(groups, positions=keys,
                            widths=(1.0*min_key_diff)/2, sym='')

                plt.rcParams.update({'font.size': 22})
                if namer.sens in namer.encoders:
                    ax = plt.gca()
                    ax.set_xticklabels(namer.get_sens_feature_vals(
                        len(data[data.columns[1]].unique())))
                else:
                    plt.xlim(np.min(sens) - 0.4*np.std(sens),
                             np.max(sens) + 0.4*np.std(sens))
                    plt.ylim(np.min(out) - 0.4*np.std(out),
                             np.max(out) + 0.4*np.std(out))

                plt.xlabel(data.columns[1])
                plt.ylabel(data.columns[0])
                plt.show()

            (effect_low, effect_high, p_val) = context_stats[i+1]
            print >> output_stream, \
                'p-value = {:.2e} ; {} = [{:.4f}, {:.4f}]'.\
                format(p_val, 'CORR', effect_low, effect_high)
            print >> output_stream

        context_stats = context_stats[0]

    # print p-value and confidence interval of correlation
    (effect_low, effect_high, p_val) = context_stats
# run network 
        for step in tqdm(xrange(FLAGS.test_length)):
          # network step
          state_feed_dict, boundary_feed_dict = feed_dict(1, shape, FLAGS.lattice_size, sim, run+step+0)
          fd = {state:state_feed_dict, boundary:boundary_feed_dict, y_1:y_1_g, small_boundary_mul:small_boundary_mul_g, small_boundary_add:small_boundary_add_g}
          mse, y_1_g = sess.run([mean_squared_error, y_2],feed_dict=fd)
          # calc error
          mse_error[sim, step] = mse

    # step count variable for plotting
    x = np.arange(FLAGS.test_length)

    # mse 
    mse_error_mean, mse_error_std = calc_mean_and_std(mse_error)

    plt.figure(figsize = (6,12))
    plt.style.use('seaborn-darkgrid')

    font = {'family' : 'normal',
        'weight' : 'normal',
        'size'   : 16}

    matplotlib.rc('font', **font)

    plt.title(str(shape[0]) + "x" + str(shape[1]) + " EM Simulation", y=1.00, fontsize="x-large")
    plt.errorbar(x, mse_error_mean, yerr=mse_error_std, c='y', capsize=0, lw=1.0)
    plt.xlabel('step', fontsize="x-large")
    plt.ylabel('MSError', fontsize="x-large")
    plt.legend(loc="upper_left")
    plt.savefig("figs/" + str(shape[0]) + "x" + str(shape[1]) + "_2d_em_error_plot.png")
#v2=(p2_st.y>-1.0)
v2 = arange(len(p2_st.y))

if verbose: print 'Calculate analytical solution'
h,z = analytic_sol(p2_st.x[v2])
qexact = 1.0




#Plot the stages##############################################################
if verbose: print 'Create Stage plot'
pyplot.clf()
pyplot.plot(p2_st.x[v2], p2_st.stage[tid,v2], 'b.-', label='numerical stage') # 0*T/6
pyplot.plot(p2_st.x[v2], h+z,'r-', label='analytical stage')
pyplot.plot(p2_st.x[v2], z,'k-', label='bed elevation')
pyplot.xlim((5,20))
pyplot.title('Stage at time = %s secs'% p2_st.time[tid])
##pyplot.ylim(-5.0,5.0)
pyplot.legend(loc='best')
pyplot.xlabel('Xposition')
pyplot.ylabel('Stage')
pyplot.savefig('stage_plot.png')


#Plot the momentums##########################################################
if verbose: print 'Create Momentum plot'
pyplot.clf()
pyplot.plot(p2_st.x[v2], p2_st.xmom[tid,v2], 'b.-', label='numerical') # 0*T/6
pyplot.plot(p2_st.x[v2], qexact*ones(len(p2_st.x[v2])),'r-', label='analytical')
pyplot.xlim((5,20))
pyplot.title('Xmomentum at time = %s secs'% p2_st.time[tid])
bzarr=np.ones_like(zarr)
bzarr2=2*np.ones_like(zarr)
tzarr=5.5919E-2+2.3242E-1*zarr-2.4136E-2*zarr**2.
norm=ngal/(4*np.pi*(180/np.pi)**2*np.sum(nzarr)*(zf-z0)/nz)
nzarr*=norm
norm2=ngal2/(4*np.pi*(180/np.pi)**2*np.sum(nzarr2)*(zf-z0)/nz)
nzarr2*=norm2

np.savetxt("Nz_test.txt",np.transpose([zarr,nzarr]))
np.savetxt("Nz2_test.txt",np.transpose([zarr,nzarr2]))
np.savetxt("Tz_test.txt",np.transpose([zarr,tzarr]))
np.savetxt("Bz_test.txt",np.transpose([zarr,bzarr]))
np.savetxt("Bz2_test.txt",np.transpose([zarr,bzarr2]))
np.savetxt("nuTable.txt",np.transpose([nu0_arr,nuf_arr]))

plt.plot(zarr,nzarr); plt.plot(zarr,nzarr2); plt.show()
plt.plot(zarr,bzarr); plt.show()
plt.plot(zarr,tzarr); plt.show()
def test_gibbs_update_synapses():
    """
    Test the mean field updates for synapses
    """
    population = create_simple_population(N=5, T=10000)
    neuron = population.neuron_models[0]
    synapse = neuron.synapse_models[0]
    data = neuron.data_list[0]

    plt.ion()
    plt.figure()
    plt.plot(data.psi, '-b')
    plt.plot(np.nonzero(data.counts)[0], data.counts[data.counts>0], 'ko')
    psi = plt.plot(data.psi, '-r')
    plt.show()


    A_true = neuron.An.copy()
    print "A_true: ", neuron.An
    print "W_true: ", neuron.weights
    print "b_true: ", neuron.bias

    # Initialize to a random connections
    neuron.An = np.random.rand(5) < 0.5

    print "--" * 20

    raw_input("Press enter to continue...")

    N_iter = 1000

Is your System Free of Underlying Vulnerabilities?
Find Out Now