當前位置: 首頁>>代碼示例>>Python>>正文


Python pyplot.xscale方法代碼示例

本文整理匯總了Python中matplotlib.pyplot.xscale方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.xscale方法的具體用法?Python pyplot.xscale怎麽用?Python pyplot.xscale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.pyplot的用法示例。


在下文中一共展示了pyplot.xscale方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _plot_matplotlib

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def _plot_matplotlib(subset_sizes, data_list, mmr):
    """ Plots learning curve using matplotlib backend.
    Args:
        subset_sizes: list of dataset sizes on which the evaluation was done
        data_list: list of ROC AUC scores corresponding to subset_sizes
        mmr: what MMR the data is taken from
    """
    plt.plot(subset_sizes, data_list[0], lw=2)
    plt.plot(subset_sizes, data_list[1], lw=2)

    plt.legend(['Cross validation error', 'Test error'])
    plt.xscale('log')
    plt.xlabel('Dataset size')
    plt.ylabel('Error')

    if mmr:
        plt.title('Learning curve plot for %d MMR' % mmr)
    else:
        plt.title('Learning curve plot')

    plt.show() 
開發者ID:andreiapostoae,項目名稱:dota2-predictor,代碼行數:23,代碼來源:learning_curve.py

示例2: plot_cumulative_recall_differences

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def plot_cumulative_recall_differences(cumulative_recalls, path):
  """Plot differences in cumulative recall between groups up to time T."""
  plt.figure(figsize=(8, 3))
  style = {'dynamic': '-', 'static': '--'}

  for setting, recalls in cumulative_recalls.items():
    abs_array = np.mean(np.abs(recalls[0::2, :] - recalls[1::2, :]), axis=0)

    plt.plot(abs_array, style[setting], label=setting)

  plt.title(
      'Recall gap for EO agent in dynamic vs static environments', fontsize=16)
  plt.yscale('log')
  plt.xscale('log')
  plt.ylabel('TPR gap', fontsize=16)
  plt.xlabel('# steps', fontsize=16)
  plt.grid(True)
  plt.legend()
  plt.tight_layout()
  _write(path) 
開發者ID:google,項目名稱:ml-fairness-gym,代碼行數:22,代碼來源:lending_plots.py

示例3: plot_loss_change

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def plot_loss_change(self, sma=1, n_skip_beginning=10, n_skip_end=5, y_lim=(-0.01, 0.01)):
        """
        Plots rate of change of the loss function.
        Parameters:
            sma - number of batches for simple moving average to smooth out the curve.
            n_skip_beginning - number of batches to skip on the left.
            n_skip_end - number of batches to skip on the right.
            y_lim - limits for the y axis.
        """
        derivatives = self.get_derivatives(sma)[n_skip_beginning:-n_skip_end]
        lrs = self.lrs[n_skip_beginning:-n_skip_end]
        plt.ylabel("rate of loss change")
        plt.xlabel("learning rate (log scale)")
        plt.plot(lrs, derivatives)
        plt.xscale('log')
        plt.ylim(y_lim)
        plt.show() 
開發者ID:surmenok,項目名稱:keras_lr_finder,代碼行數:19,代碼來源:lr_finder.py

示例4: plot_alt_temp_mole

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def plot_alt_temp_mole(atmosphere=None, temp=None, alt_ref=None, mole=None):
    """Plot-helping function
    """
    if atmosphere is True:
        alt, pre, temp, mole, alt_ref = swifile(atmosphere)
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.plot(mole*1.e-6,alt_ref,'b-')  # ,label='Number density(SSL=60)')
    plt.xlabel('Number density [cm$^{-3}$]',fontsize=18,weight='bold')
    plt.xscale('log')
    plt.ylabel('Altitude [km]',fontsize=18,weight='bold')
    ax2=ax.twiny()
    ax2.plot(temp,alt_ref,'k-', label='Temperature')
    ax2.set_xlabel("Temperature [K]",fontsize=18,weight='bold')
    ax2.plot([],[],'b-', label='H$_{2}$O Number density')
    plt.legend()
    fig.tight_layout(pad=0.4)
    return fig 
開發者ID:atmtools,項目名稱:typhon,代碼行數:20,代碼來源:__init__.py

示例5: figure_5_4

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def figure_5_4():
    runs = 10
    episodes = 100000
    for run in range(runs):
        rewards = []
        for episode in range(0, episodes):
            reward, trajectory = play()
            if trajectory[-1] == ACTION_END:
                rho = 0
            else:
                rho = 1.0 / pow(0.5, len(trajectory))
            rewards.append(rho * reward)
        rewards = np.add.accumulate(rewards)
        estimations = np.asarray(rewards) / np.arange(1, episodes + 1)
        plt.plot(estimations)
    plt.xlabel('Episodes (log scale)')
    plt.ylabel('Ordinary Importance Sampling')
    plt.xscale('log')

    plt.savefig('../images/figure_5_4.png')
    plt.close() 
開發者ID:ShangtongZhang,項目名稱:reinforcement-learning-an-introduction,代碼行數:23,代碼來源:infinite_variance.py

示例6: figure_5_3

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def figure_5_3():
    true_value = -0.27726
    episodes = 10000
    runs = 100
    error_ordinary = np.zeros(episodes)
    error_weighted = np.zeros(episodes)
    for i in tqdm(range(0, runs)):
        ordinary_sampling_, weighted_sampling_ = monte_carlo_off_policy(episodes)
        # get the squared error
        error_ordinary += np.power(ordinary_sampling_ - true_value, 2)
        error_weighted += np.power(weighted_sampling_ - true_value, 2)
    error_ordinary /= runs
    error_weighted /= runs

    plt.plot(error_ordinary, label='Ordinary Importance Sampling')
    plt.plot(error_weighted, label='Weighted Importance Sampling')
    plt.xlabel('Episodes (log scale)')
    plt.ylabel('Mean square error')
    plt.xscale('log')
    plt.legend()

    plt.savefig('../images/figure_5_3.png')
    plt.close() 
開發者ID:ShangtongZhang,項目名稱:reinforcement-learning-an-introduction,代碼行數:25,代碼來源:blackjack.py

示例7: diagnostics_SNR

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def diagnostics_SNR(self): 
        """ Plots SNR distributions of ref and test object spectra """
        print("Diagnostic for SNRs of reference and survey objects")
        fig = plt.figure()
        data = self.test_SNR
        plt.hist(data, bins=int(np.sqrt(len(data))), alpha=0.5, facecolor='r', 
                label="Survey Objects")
        data = self.tr_SNR
        plt.hist(data, bins=int(np.sqrt(len(data))), alpha=0.5, color='b',
                label="Ref Objects")
        plt.legend(loc='upper right')
        #plt.xscale('log')
        plt.title("SNR Comparison Between Reference and Survey Objects")
        #plt.xlabel("log(Formal SNR)")
        plt.xlabel("Formal SNR")
        plt.ylabel("Number of Objects")
        return fig 
開發者ID:annayqho,項目名稱:TheCannon,代碼行數:19,代碼來源:dataset.py

示例8: example1

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def example1():
    """
    Compute the GRADEV of a white phase noise. Compares two different 
    scenarios. 1) The original data and 2) ADEV estimate with gap robust ADEV.
    """
    N = 1000
    f = 1
    y = np.random.randn(1,N)[0,:]
    x = [xx for xx in np.linspace(1,len(y),len(y))]
    x_ax, y_ax, (err_l, err_h), ns = allan.gradev(y,data_type='phase',rate=f,taus=x)
    plt.errorbar(x_ax, y_ax,yerr=[err_l,err_h],label='GRADEV, no gaps')
    
    
    y[int(np.floor(0.4*N)):int(np.floor(0.6*N))] = np.NaN # Simulate missing data
    x_ax, y_ax, (err_l, err_h) , ns = allan.gradev(y,data_type='phase',rate=f,taus=x)
    plt.errorbar(x_ax, y_ax,yerr=[err_l,err_h], label='GRADEV, with gaps')
    plt.xscale('log')
    plt.yscale('log')
    plt.grid()
    plt.legend()
    plt.xlabel('Tau / s')
    plt.ylabel('Overlapping Allan deviation')
    plt.show() 
開發者ID:aewallin,項目名稱:allantools,代碼行數:25,代碼來源:gradev-demo.py

示例9: test_markevery_log_scales

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def test_markevery_log_scales():
    cases = [None,
         8,
         (30, 8),
         [16, 24, 30], [0,-1],
         slice(100, 200, 3),
         0.1, 0.3, 1.5,
         (0.0, 0.1), (0.45, 0.1)]

    cols = 3
    gs = matplotlib.gridspec.GridSpec(len(cases) // cols + 1, cols)

    delta = 0.11
    x = np.linspace(0, 10 - 2 * delta, 200) + delta
    y = np.sin(x) + 1.0 + delta

    for i, case in enumerate(cases):
        row = (i // cols)
        col = i % cols
        plt.subplot(gs[row, col])
        plt.title('markevery=%s' % str(case))
        plt.xscale('log')
        plt.yscale('log')
        plt.plot(x, y, 'o', ls='-', ms=4,  markevery=case) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:26,代碼來源:test_axes.py

示例10: _save_plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def _save_plot(learning_rates: List[float], losses: List[float], save_path: str):

    try:
        import matplotlib

        matplotlib.use("Agg")  # noqa
        import matplotlib.pyplot as plt

    except ModuleNotFoundError as error:

        logger.warn(
            "To use allennlp find-learning-rate, please install matplotlib: pip install matplotlib>=2.2.3 ."
        )
        raise error

    plt.ylabel("loss")
    plt.xlabel("learning rate (log10 scale)")
    plt.xscale("log")
    plt.plot(learning_rates, losses)
    logger.info(f"Saving learning_rate vs loss plot to {save_path}.")
    plt.savefig(save_path) 
開發者ID:allenai,項目名稱:allennlp,代碼行數:23,代碼來源:find_learning_rate.py

示例11: test_markevery_log_scales

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def test_markevery_log_scales():
    cases = [None,
             8,
             (30, 8),
             [16, 24, 30], [0, -1],
             slice(100, 200, 3),
             0.1, 0.3, 1.5,
             (0.0, 0.1), (0.45, 0.1)]

    cols = 3
    gs = matplotlib.gridspec.GridSpec(len(cases) // cols + 1, cols)

    delta = 0.11
    x = np.linspace(0, 10 - 2 * delta, 200) + delta
    y = np.sin(x) + 1.0 + delta

    for i, case in enumerate(cases):
        row = (i // cols)
        col = i % cols
        plt.subplot(gs[row, col])
        plt.title('markevery=%s' % str(case))
        plt.xscale('log')
        plt.yscale('log')
        plt.plot(x, y, 'o', ls='-', ms=4,  markevery=case) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:26,代碼來源:test_axes.py

示例12: plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def plot(self, n_skip:int=0, n_max:Optional[int]=None, lim_y:Optional[Tuple[float,float]]=None) -> None:
        r'''
        Plot the loss as a function of the LR.

        Arguments:
            n_skip: Number of initial iterations to skip in plotting
            n_max: Maximum iteration number to plot
            lim_y: y-range for plotting
        '''

        # TODO: Decide on whether to keep this; could just pass to plot_lr_finders

        with sns.axes_style(self.plot_settings.style), sns.color_palette(self.plot_settings.cat_palette):
            plt.figure(figsize=(self.plot_settings.w_mid, self.plot_settings.h_mid))
            plt.plot(self.history['lr'][n_skip:n_max], self.history['loss'][n_skip:n_max], label='Training loss', color='g')
            if np.log10(self.lr_bounds[1])-np.log10(self.lr_bounds[0]) >= 3: plt.xscale('log')
            plt.ylim(lim_y)
            plt.grid(True, which="both")
            plt.legend(loc=self.plot_settings.leg_loc, fontsize=self.plot_settings.leg_sz)
            plt.xticks(fontsize=self.plot_settings.tk_sz, color=self.plot_settings.tk_col)
            plt.yticks(fontsize=self.plot_settings.tk_sz, color=self.plot_settings.tk_col)
            plt.ylabel("Loss", fontsize=self.plot_settings.lbl_sz, color=self.plot_settings.lbl_col)
            plt.xlabel("Learning rate", fontsize=self.plot_settings.lbl_sz, color=self.plot_settings.lbl_col)
            plt.show() 
開發者ID:GilesStrong,項目名稱:lumin,代碼行數:26,代碼來源:opt_callbacks.py

示例13: plot_classif_perf

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def plot_classif_perf(list_overall_best_score_classif, list_overall_best_score_classes_classif, list_num_samples,
                      Dataset):
    for iter, [scores_classif, dataset, method, num_task] in enumerate(list_overall_best_score_classif):

        if dataset == Dataset and num_task == 1 and method == "Baseline":

            scores_mean = scores_classif.mean(0)
            scores_std = scores_classif.std(0)

            # there should be only one curve by dataset
            plt.plot(list_num_samples, scores_mean)
            plt.fill_between(list_num_samples, scores_mean - scores_std, scores_mean + scores_std, alpha=0.4)

    plt.xscale('log')
    plt.xlabel("Number of Samples")
    plt.ylabel("Accuracy")
    plt.ylim([0, 100])
    plt.title('Accuracy in fonction number of samples used')
    plt.savefig(os.path.join(save_dir, Dataset + "_Accuracy_NbSamples.png"))
    plt.clf() 
開發者ID:TLESORT,項目名稱:Generative_Continual_Learning,代碼行數:22,代碼來源:print_figures.py

示例14: plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def plot(self, min_val=-10, max_val=10, step_size=0.1, figsize=(10, 5), xlabel=None, ylabel='Probability', xticks=None, yticks=None, log_xscale=False, log_yscale=False, file_name=None, show=True, fig=None, *args, **kwargs):
        if fig is None:
            if not show:
                mpl.rcParams['axes.unicode_minus'] = False
                plt.switch_backend('agg')
            fig = plt.figure(figsize=figsize)
            fig.tight_layout()
        xvals = np.arange(min_val, max_val, step_size)
        plt.plot(xvals, [torch.exp(self.log_prob(x)) for x in xvals], *args, **kwargs)
        if log_xscale:
            plt.xscale('log')
        if log_yscale:
            plt.yscale('log', nonposy='clip')
        if xticks is not None:
            plt.xticks(xticks)
        if yticks is not None:
            plt.xticks(yticks)
        # if xlabel is None:
        #     xlabel = self.name
        plt.xlabel(xlabel)
        plt.ylabel(ylabel)
        if file_name is not None:
            plt.savefig(file_name)
        if show:
            plt.show() 
開發者ID:pyprob,項目名稱:pyprob,代碼行數:27,代碼來源:distribution.py

示例15: test_ioworker_performance

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import xscale [as 別名]
def test_ioworker_performance(nvme0n1):
    import matplotlib.pyplot as plt

    output_io_per_second = []
    percentile_latency = dict.fromkeys([90, 99, 99.9, 99.99, 99.999])
    nvme0n1.ioworker(io_size=8,
                     lba_random=True,
                     read_percentage=100,
                     output_io_per_second=output_io_per_second,
                     output_percentile_latency=percentile_latency,
                     time=10).start().close()
    logging.info(output_io_per_second)
    logging.info(percentile_latency)

    X = []
    Y = []
    for _, k in enumerate(percentile_latency):
        X.append(k)
        Y.append(percentile_latency[k])

    plt.plot(X, Y)
    plt.xscale('log')
    plt.yscale('log')
    #plt.show() 
開發者ID:pynvme,項目名稱:pynvme,代碼行數:26,代碼來源:test_examples.py


注:本文中的matplotlib.pyplot.xscale方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。