How to use the matplotlib.pyplot.subplots function in matplotlib

To help you get started, we’ve selected a few matplotlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iancze / PSOAP / tests / test_orbit_astrometry_triple.py View on Github external
def test_out_vel():
    # Plot velocities as function of time for one period
    fig, ax = plt.subplots(nrows=3, sharex=True, figsize=(8,8))

    ax[0].plot(dates_out, vAs)
    ax[0].set_ylabel(r"$v_A$ km/s")

    ax[1].plot(dates_out, vBs)
    ax[1].set_ylabel(r"$v_B$ km/s")

    ax[2].plot(dates_out, vCs)
    ax[2].set_ylabel(r"$v_C$ km/s")

    ax[-1].set_xlabel("date")
    fig.savefig(outdir + "orbit_out_vel.png", dpi=400)
github alphacsc / alphacsc / benchmarks / function_benchmarks / compute_ztX.py View on Github external
for n_atoms in n_atoms_range:
        for sparsity in sparsity_range:
            for n_times_atom in n_times_atom_range:
                for n_times_valid in n_times_valid_range:
                    for func in all_func:
                        print('%d/%d, %s' % (k, n_runs, func.__name__))
                        k += 1
                        results.append(
                            run_one(n_atoms, sparsity, n_times_atom,
                                    n_times_valid, func))

    df = pd.DataFrame(results, columns=[
        'n_atoms', 'sparsity', 'n_times_atom', 'n_times_valid', 'func',
        'duration'
    ])
    fig, axes = plt.subplots(2, 2, figsize=(10, 8))
    axes = axes.ravel()

    def plot(index, ax):
        pivot = df.pivot_table(columns='func', index=index, values='duration',
                               aggfunc=gmean)
        pivot.plot(ax=ax)
        ax.set_xscale('log')
        ax.set_yscale('log')
        ax.set_ylabel('duration')

    plot('n_atoms', axes[0])
    plot('n_times_atom', axes[1])
    plot('sparsity', axes[2])
    plot('n_times_valid', axes[3])
    plt.tight_layout()
    plt.show()
github Zarcher0 / BootAnimationMaker / ImgProcess.py View on Github external
:param bg_conf: background component configuration
    :param dyn_conf: dynamic component configuration
    :param sta_confs: static component configurations list
    :return: None
    """
    import matplotlib.pyplot as plt

    im_name_list = os.listdir(dyn_conf.get('ext_dir', None))
    im_path_list = []
    for im_name in im_name_list:
        im_path_list.append(os.path.join(dyn_conf.get('ext_dir', None), im_name))

    im_path = im_path_list[0]
    bg = combination_prev(im_path, bg_conf, dyn_conf, sta_confs)

    fig, ax = plt.subplots()
    ax.imshow(bg)

    plt.show()
github castelao / CoTeDe / cotede / humanqc / humaneval.py View on Github external
def plot(self):
        """
        """
        self.fig, self.ax = plt.subplots()
        self.line, = self.ax.plot(self.x, self.z, 'b.',
                picker=10) # 5 points tolerance
        # Plot the bad ones
        self.ax.plot(self.x[self.baseflag==False],
                self.z[self.baseflag==False], 'r^')

        # Plot the dubious ones
        self.ax.plot(
                self.x[self.humanflag=='doubt'],
                self.z[self.humanflag=='doubt'],
                'D', color='magenta')

        self.ax.plot(self.x[self.fails], self.z[self.fails], 'o', ms=12,
                alpha=0.4, color='cyan', visible=True)
github 5GenCrypto / obfuscation / scripts / graph-secparam.py View on Github external
idsizes = [i / MB for i in idsizes]
    andsizes = [i / MB for i in andsizes]
    xorsizes = [i / MB for i in xorsizes]

    _, ideval = utils.dir_evaltime(idfiles)
    _, andeval = utils.dir_evaltime(andfiles)
    _, xoreval = utils.dir_evaltime(xorfiles)
    ideval, andeval, xoreval = ideval[1:], andeval[1:], xoreval[1:]

    # sizeexp = [(4 ** 5.39) * (x ** 2) for x in xs]
    # evalexp = [(4 ** 5.84) * (x ** 2) / 1000 for x in xs]

    ind = np.arange(len(xs))
    width = 0.2

    fig, axes = plt.subplots(nrows=1, ncols=3)

    ax1 = axes.flat[0]

    p1 = ax1.bar(ind + width, idtimes, width, color='black')
    p2 = ax1.bar(ind + 2 * width, andtimes, width, color='gray')
    p3 = ax1.bar(ind + 3 * width, xortimes, width, color='white')
    ax1.legend((p1[0], p2[0], p3[0]), ('ID', 'AND', 'XOR'), loc='upper left')
    ax1.set_xlabel(r'Security Parameter')
    ax1.set_ylabel(r'Time (minutes)')
    ax1.set_xticks(ind + 0.5)
    ax1.set_xticklabels(xs)

    ax1 = axes.flat[1]

    p1 = ax1.bar(ind + width, idsizes, width, color='black')
    p2 = ax1.bar(ind + 2 * width, andsizes, width, color='gray')
github adammoss / nnest / nnest / sampler.py View on Github external
def _plot_trace(self, samples, latent_samples):
        if self.log_dir is not None:
            fig, ax = plt.subplots(self.x_dim, 2, figsize=(10, self.x_dim), sharex=True)
            for i in range(self.x_dim):
                ax[i, 0].plot(samples[0, :, i])
                ax[i, 1].plot(latent_samples[0, 0:1000, i])
            plt.savefig(os.path.join(self.log_dir, 'plots', 'trace.png'))
            plt.close()
github aaren / wavelets / wavelets / transform.py View on Github external
def plot_power(self, ax=None, coi=True):
        """Create a basic wavelet power plot with time on the
        x-axis, scale on the y-axis, and a cone of influence
        overlaid.

        Requires matplotlib.
        """
        import matplotlib.pyplot as plt

        if not ax:
            fig, ax = plt.subplots()

        Time, Scale = np.meshgrid(self.time, self.scales)
        ax.contourf(Time, Scale, self.wavelet_power, 100)

        ax.set_yscale('log')
        ax.grid(True)

        if coi:
            coi_time, coi_scale = self.coi
            ax.fill_between(x=coi_time,
                            y1=coi_scale,
                            y2=self.scales.max(),
                            color='gray',
                            alpha=0.3)

        ax.set_xlim(self.time.min(), self.time.max())
github sperez8 / HivePanelExplorer / scripts / network_simulation.py View on Github external
def keystone_quantitative_feature_plot(net_path, networkNames, figurePath, featurePath, featureFile, features, percentNodes, bcMinValue):
	networks,treatments = get_network_fullnames(networkNames)
	edgetype = 'pos'
	colName = nx.betweenness_centrality.__name__.replace('_',' ').capitalize()
	#modName = nm.node_modularity.__name__.replace('_',' ').capitalize()

	fig, axes = plt.subplots(len(features))
	netNames = treatments

	for location in networkNames.keys():
		for ax,f in zip(axes,features):
			featureValues = []
			for i,t in enumerate(treatments):
				featureValues.append([])
				featureTableFile = os.path.join(featurePath,featureFile+'_{0}_{1}_{2}.txt'.format(edgetype,location,t))
				featureTable = np.loadtxt(featureTableFile,delimiter='\t', dtype='S1000')
				centcol = np.where(featureTable[0,:]==colName)[0][0]
				nodes = featureTable[np.where(featureTable[:,centcol]!=NOT_A_NODE_VALUE)][1:,0]
				featcol = np.where(featureTable[0,:]==f)[0][0]
				#modcol =  np.where(featureTable[0,:]==modName)[0][0]
				bcvalues = featureTable[1:,centcol]
				bcvalues = bcvalues[np.where(bcvalues!=NOT_A_NODE_VALUE)]
				bcvalues= list([float(k) for k in bcvalues])
github cosmo-epfl / librascal / examples / utilities / vectors_utils.py View on Github external
Author: R. Cersonsky

            Keywords:
                 key      - string corresponding to molecule built by
                            import_molecules
                 img_name - filename under which to cache the image
        """
        from ase.data import covalent_radii, atomic_numbers
        from matplotlib import pyplot, patches
        from ase.data.colors import jmol_colors
        style = {
            "horizontalalignment": "center",
            "verticalalignment": "center",
            "fontsize": 12
        }
        fig, ax = pyplot.subplots(1)

        for i, p in enumerate(self.positions[key]):
            an = atomic_numbers[self.symbols[key][i]]
            ax.text(*p[:2],
                    s=self.labels[key][i],
                    **style,
                    zorder=p[-1]+0.01
                    )
            ax.add_artist(patches.Circle(p[:2],
                                         covalent_radii[an],
                                         facecolor=jmol_colors[an],
                                         edgecolor='k',
                                         alpha=0.95,
                                         zorder=p[-1]))
        ax.axis('off')
        bounds = [*np.min(self.positions[key], axis=0), *
github haoyuanz13 / Deep_Learning / Generative Model / cycleGAN_im2im / utils.py View on Github external
def processPlot_loss_GANs(path, iteration, d_loss, g_loss):
  fig, (Ax0, Ax1) = plt.subplots(2, 1, figsize = (8, 20))

  x = np.arange(0, iteration, 1)

  Ax0.plot(x, d_loss)
  Ax0.set_title('Model D Loss vs Iterations') 
  Ax0.set_ylabel('loss value')
  Ax0.grid(True)
  

  Ax1.plot(x, g_loss)
  Ax1.set_title('Model G Loss vs Iterations')
  Ax1.set_xlabel('iteration times')
  Ax1.set_ylabel('loss value')
  Ax1.grid(True)

  plt.show()