当前位置: 首页>>代码示例>>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;未经允许,请勿转载。