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


Python pyplot.fill_betweenx方法代碼示例

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


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

示例1: plot_shape

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import fill_betweenx [as 別名]
def plot_shape(xys, z1, z2, ax, scale, scatter, symm_axis, **kwargs):
#    mx = max([y for (x, y) in m])
#    mn = min([y for (x, y) in m])
    xscl = scale# / (mx - mn)
    yscl = scale# / (mx - mn)
#    ax.scatter(z1, z2)
    if scatter:
        if 'c' not in kwargs:
            kwargs['c'] = cm.rainbow(np.linspace(0,1,xys.shape[0]))
#        ax.plot( *zip(*[(x * xscl + z1, y * yscl + z2) for (x, y) in xys]), lw=.2, c='b')
        ax.scatter( *zip(*[(x * xscl + z1, y * yscl + z2) for (x, y) in xys]), edgecolors='none', **kwargs)
    else:
        ax.plot( *zip(*[(x * xscl + z1, y * yscl + z2) for (x, y) in xys]), **kwargs)
        
    if symm_axis == 'y':
#        ax.plot( *zip(*[(-x * xscl + z1, y * yscl + z2) for (x, y) in xys]), lw=.2, c='b')
        plt.fill_betweenx( *zip(*[(y * yscl + z2, -x * xscl + z1, x * xscl + z1)
                          for (x, y) in xys]), color='gray', alpha=.2)
    elif symm_axis == 'x':
#        ax.plot( *zip(*[(x * xscl + z1, -y * yscl + z2) for (x, y) in xys]), lw=.2, c='b')
        plt.fill_between( *zip(*[(x * xscl + z1, -y * yscl + z2, y * yscl + z2)
                          for (x, y) in xys]), color='gray', alpha=.2) 
開發者ID:IDEALLab,項目名稱:airfoil-opt-gan,代碼行數:24,代碼來源:shape_plot.py

示例2: zonal_mean_plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import fill_betweenx [as 別名]
def zonal_mean_plot(obs_mean, obs_std, pred_mean, pred_std, f_hour, model_name='', out_directory=None):
    """
    Plot the zonal mean and standard deviation of observed and predicted forecast states.

    :param obs_mean: 1d DataArray with dimension 'lat': observed zonal mean
    :param obs_std: 1d DataArray with dimension 'lat': observed zonal std
    :param pred_mean: 1d DataArray with dimension 'lat': forecast zonal mean
    :param pred_std: 1d DataArray with dimension 'lat': forecast zonal std
    :param f_hour: int: forecast hour of the prediction
    :param model_name: str: name of the model
    :param out_directory: str: if not None, save the figure to this directory
    :return:
    """
    fig = plt.figure()
    fig.set_size_inches(4, 6)
    plt.fill_betweenx(obs_mean.lat, obs_mean - obs_std, obs_mean + obs_std,
                      facecolor='C0', zorder=-50, alpha=0.3)
    plt.fill_betweenx(pred_mean.lat, pred_mean - pred_std, pred_mean + pred_std,
                      facecolor='C1', zorder=-40, alpha=0.3)
    plt.plot(obs_mean, obs_mean.lat, label='observed', color='C0')
    plt.plot(pred_mean, pred_mean.lat, label='%d-hour prediction' % f_hour, color='C1')
    plt.legend(loc='best')
    plt.grid(True, color='lightgray', zorder=-100)
    plt.xlabel('zonal mean height')
    plt.ylabel('latitude')
    plt.ylim([0., 90.])
    plt.savefig('%s/%s_zonal_climo.pdf' % (out_directory, remove_chars(model_name)), bbox_inches='tight')
    plt.show() 
開發者ID:jweyn,項目名稱:DLWP,代碼行數:30,代碼來源:plot_functions.py

示例3: plot_merged_cpt_bore

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import fill_betweenx [as 別名]
def plot_merged_cpt_bore(df, figsize=None, show=True):
    fig = plt.figure(figsize=figsize)
    subplot_val = 131
    plt.subplot(subplot_val)
    plt.plot(df["qc"], -df["depth"])

    subplot_val += 1
    plt.subplot(subplot_val)
    plt.plot(df["friction_number"], -df["depth"])

    subplot_val += 1
    plt.subplot(subplot_val)
    if "SI" in df.columns:
        df = df.copy()
        df["L"] += df["SI"]
    v = df[["G", "S", "L", "C", "P"]].values

    c = ["#a76b29", "#578E57", "#0078C1", "#DBAD4B", "#708090"]
    for i in range(5):
        plt.fill_betweenx(
            -df["depth"],
            np.zeros(v.shape[0]),
            np.cumsum(v, axis=1)[:, -(i + 1)],
            color=c[i],
        )

    if show:
        plt.show()
    return fig 
開發者ID:ritchie46,項目名稱:pygef,代碼行數:31,代碼來源:plot_utils.py

示例4: plot_bore

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import fill_betweenx [as 別名]
def plot_bore(df, figsize=(11, 8), show=True, dpi=100):
    df = df.copy()

    fig = plt.figure(figsize=figsize, dpi=dpi)

    v = df[["G", "S", "L", "C", "P"]].values
    v[:, 2] += df["SI"].values
    v[np.argwhere(v.sum(1) < 0)] = np.nan

    c = ["#a76b29", "#578E57", "#0078C1", "#DBAD4B", "#708090"]

    for i in range(5):
        plt.fill_betweenx(
            -np.repeat(df["depth_top"], 2),
            np.zeros(v.shape[0] * 2),
            np.roll(np.repeat(np.cumsum(v, axis=1)[:, -(i + 1)], 2), 1),
            color=c[i],
        )

    legend_dict = {
        "Gravel": "#708090",
        "Sand": "#DBAD4B",
        "Loam": "#0078C1",
        "Clay": "#578E57",
        "Peat": "#a76b29",
    }
    patch_list = []
    for key in legend_dict:
        data_key = mpatches.Patch(color=legend_dict[key], label=key)
        patch_list.append(data_key)

    plt.legend(handles=patch_list, bbox_to_anchor=(1, 1), loc="upper left")

    if show:
        plt.show()
    return fig 
開發者ID:ritchie46,項目名稱:pygef,代碼行數:38,代碼來源:plot_utils.py

示例5: dispaly_silhouette

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import fill_betweenx [as 別名]
def dispaly_silhouette(self, output_dir, assigned_clusters):
        num_clusters = len(set(assigned_clusters))
        plt.clf()
        y_lower = 10
        all_colors = colors(num_clusters)
        for i in range(num_clusters):
            # Aggregate the silhouette scores for samples belonging to
            # cluster i, and sort them
            selection = assigned_clusters == i
            ith_cluster_silhouette_values = self.silhouette_values[selection]
            ith_cluster_silhouette_values.sort()
            size_cluster_i = ith_cluster_silhouette_values.shape[0]
            y_upper = y_lower + size_cluster_i
            color = all_colors[i]
            plt.fill_betweenx(np.arange(y_lower, y_upper),
                              0, ith_cluster_silhouette_values,
                              facecolor=color, edgecolor=color, alpha=0.7)
            # Label the silhouette plots with their cluster numbers at the
            # middle
            plt.text(-0.05, y_lower + 0.5 * size_cluster_i, str(i))
            # Compute the new y_lower for next plot
            y_lower = y_upper + 10  # 10 for the 0 samples
        plt.title('The silhouette plot for the various clusters.')
        plt.xlabel('The silhouette coefficient values')
        plt.ylabel('Cluster label')
        # The vertical line for average silhoutte score of all the values
        plt.axvline(x=self.silhouette_avg, color='red', linestyle='--')
        plt.yticks([])  # Clear the yaxis labels / ticks
        plt.xticks([-0.1, 0, 0.2, 0.4, 0.6, 0.8, 1])
        plt.savefig(path.join(output_dir, 'silhouette.png'))
        plt.clf() 
開發者ID:ANSSI-FR,項目名稱:SecuML,代碼行數:33,代碼來源:silhouette.py

示例6: seismic_wiggle

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import fill_betweenx [as 別名]
def seismic_wiggle(section, dt, ranges=None, scale=1., color='k',
                   normalize=False):
    """
    Plot a seismic section (numpy 2D array matrix) as wiggles.

    Parameters:

    * section :  2D array
        matrix of traces (first dimension time, second dimension traces)
    * dt : float
        sample rate in seconds
    * ranges : (x1, x2)
        min and max horizontal values (default trace number)
    * scale : float
        scale factor multiplied by the section values before plotting
    * color : tuple of strings
        Color for filling the wiggle, positive  and negative lobes.
    * normalize :
        True to normalizes all trace in the section using global max/min
        data will be in the range (-0.5, 0.5) zero centered

    .. warning::
        Slow for more than 200 traces, in this case decimate your
        data or use ``seismic_image``.

    """
    npts, ntraces = section.shape  # time/traces
    if ntraces < 1:
        raise IndexError("Nothing to plot")
    if npts < 1:
        raise IndexError("Nothing to plot")
    t = numpy.linspace(0, dt*npts, npts)
    amp = 1.  # normalization factor
    gmin = 0.  # global minimum
    toffset = 0.  # offset in time to make 0 centered
    if normalize:
        gmax = section.max()
        gmin = section.min()
        amp = (gmax - gmin)
        toffset = 0.5
    pyplot.ylim(max(t), 0)
    if ranges is None:
        ranges = (0, ntraces)
    x0, x1 = ranges
    # horizontal increment
    dx = (x1 - x0)/ntraces
    pyplot.xlim(x0, x1)
    for i, trace in enumerate(section.transpose()):
        tr = (((trace - gmin)/amp) - toffset)*scale*dx
        x = x0 + i*dx  # x positon for this trace
        pyplot.plot(x + tr, t, 'k')
        pyplot.fill_betweenx(t, x + tr, x, tr > 0, color=color) 
開發者ID:igp-gravity,項目名稱:geoist,代碼行數:54,代碼來源:giplt.py


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