当前位置: 首页>>代码示例>>Python>>正文


Python pyplot.fill方法代码示例

本文整理汇总了Python中matplotlib.pyplot.fill方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.fill方法的具体用法?Python pyplot.fill怎么用?Python pyplot.fill使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.pyplot的用法示例。


在下文中一共展示了pyplot.fill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plot_polygon

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def plot_polygon(poly, symbol='k-', **kwargs):
    """Plots a polygon using the given symbol."""
    for i in range(poly.GetGeometryCount()):
        subgeom = poly.GetGeometryRef(i)
        x, y = zip(*subgeom.GetPoints())
        plt.plot(x, y, symbol, **kwargs)

# Use this function to fill polygons (shown shortly after
# this listing in the text). Uncomment this one and comment
# out the one above.
# def plot_polygon(poly, symbol='w', **kwargs):
#     """Plots a polygon using the given symbol."""
#     for i in range(poly.GetGeometryCount()):
#         x, y = zip(*poly.GetGeometryRef(i).GetPoints())
#         plt.fill(x, y, symbol, **kwargs)


# This function is new. 
开发者ID:cgarrard,项目名称:osgeopy-code,代码行数:20,代码来源:listing13_3.py

示例2: AreaPlot

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def AreaPlot(self, Lon, Lat, Set=['y',1,'k',1]):

    x, y = self._map(Lon, Lat)

    if Set[0]:
      self._zo += 1
      plt.fill(x, y, color = Set[0],
                     alpha = Set[1],
                     zorder = self._zo)
    if Set[2]:
      self._zo += 1
      plt.plot(x, y, Set[2],
                     linewidth = Set[3],
                     zorder = self._zo)

  #--------------------------------------------------------------------------------------- 
开发者ID:igp-gravity,项目名称:geoist,代码行数:18,代码来源:MapTools.py

示例3: make_topography_overlay_4_blockplot

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def make_topography_overlay_4_blockplot(self, cell_number, direction):
        p1, p2 = self.calculate_p1p2(direction, cell_number)
        resx = self.model._grid.topography.resolution[0]
        resy = self.model._grid.topography.resolution[1]
        print('p1', p1, 'p2', p2)
        x, y, z = self._slice_topo_4_sections(p1, p2, resx, resy)
        if direction == 'x':
            a = np.vstack((y, z)).T
            ext = self.model._grid.regular_grid.extent[[2, 3]]
        elif direction == 'y':
            a = np.vstack((x, z)).T
            ext = self.model._grid.regular_grid.extent[[0, 1]]
        a = np.append(a,
                      ([ext[1], a[:, 1][-1]],
                       [ext[1], self.model._grid.regular_grid.extent[5]],
                       [ext[0], self.model._grid.regular_grid.extent[5]],
                       [ext[0], a[:, 1][0]]))
        line = a.reshape(-1, 2)
        plt.fill(line[:, 0], line[:, 1], color='k') 
开发者ID:cgre-aachen,项目名称:gempy,代码行数:21,代码来源:_visualization_2d.py

示例4: plot_optimizer

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def plot_optimizer(opt, lower, upper):
    import matplotlib.pyplot as plt
    plt.set_cmap("viridis")

    if not opt.models:
        print('Can not plot opt, since models do not exist yet.')
        return
    model = opt.models[-1]
    x = np.linspace(lower, upper).reshape(-1, 1)
    x_model = opt.space.transform(x)

    # Plot Model(x) + contours
    y_pred, sigma = model.predict(x_model, return_std=True)
    plt.plot(x, -y_pred, "g--", label=r"$\mu(x)$")
    plt.fill(np.concatenate([x, x[::-1]]),
             np.concatenate([-y_pred - 1.9600 * sigma,
                             (-y_pred + 1.9600 * sigma)[::-1]]),
             alpha=.2, fc="g", ec="None")

    # Plot sampled points
    plt.plot(opt.Xi, -np.array(opt.yi),
             "r.", markersize=8, label="Observations")

    # Adjust plot layout
    plt.grid()
    plt.legend(loc='best')
    plt.show() 
开发者ID:thomasahle,项目名称:fastchess,代码行数:29,代码来源:tune.py

示例5: negative_contour_area

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def negative_contour_area(mpl_obj):
    """
    Returns a array of contour levels and
    corresponding cumulative area of contours
    specifically used for calculating negative contour's area when the contours are depth of lake
    # Refer: Nikolai Shokhirev http://www.numericalexpert.com/blog/area_calculation/

    :param mpl_obj: Matplotlib contour object
    :return: [(level1, area1), (level1, area1+area2)]
    """
    n_c = len(mpl_obj.collections)  # n_c = no of contours
    print 'No. of contours = {0}'.format(n_c)
    # area = 0.0000
    cont_area_array = []
    for contour in range(n_c):
        n_p = len(mpl_obj.collections[contour].get_paths())
        zc = mpl_obj.levels[contour]
        print zc
        print n_p
        area = 0.000
        for path in range(n_p):
            p = mpl_obj.collections[contour].get_paths()[path]
            v = p.vertices
            l = len(v)
            s = 0.0000
            # plt.figure()
            # plt.fill(v[:, 0], v[:, 1], facecolor='b')
            # plt.grid()
            # plt.show()
            for i in range(l):
                j = (i + 1) % l
                s += (v[j, 0] - v[i, 0]) * (v[j, 1] + v[i, 1])
            poly_area = abs(0.5 * s)
            area += poly_area
        cont_area_array.append((zc, area))
    return cont_area_array 
开发者ID:Kirubaharan,项目名称:hydrology,代码行数:38,代码来源:smg_stage_vol.py

示例6: poly_area

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def poly_area(xy):
    """
    Calculates polygon area
    x = xy[:,0], y[xy[:,1]
    :param xy:
    :return:
    """
    l = len(xy)
    s = 0.0
    for i in range(l):
        j = (i+1) % l
        s += (xy[j, 0] - xy[i, 0]) * (xy[j,1]+ xy[i,1])
    return -0.5*s

# # zero contour has two paths 0, 1
# p_0_0 = CS.collections[0].get_paths()[0]    # CS.collections[index of contour].get_paths()[index of path]
# p_0_1 = CS.collections[0].get_paths()[1]
# v_0_0 = p_0_0.vertices
# v_0_1 = p_0_1.vertices
# area_0_0 = abs(poly_area(v_0_0))
# area_0_1 = abs(poly_area(v_0_1))
# area_0 = area_0_0 + area_0_1
# z_0 = CS.levels[0]
# # print z_0, area_0
# plt.fill(v_0_0[:,0], v_0_0[:,1], facecolor='g')
# plt.show()
# # 0.4 contour has three paths 0,1,2
# print len(CS.collections[21].get_paths()) 
开发者ID:Kirubaharan,项目名称:hydrology,代码行数:30,代码来源:ch_591_stage_area.py

示例7: create_figure

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def create_figure():
    plt.figure()
    x = np.linspace(0, 1, 15)

    # line plot
    plt.plot(x, x ** 2, "b-")

    # marker
    plt.plot(x, 1 - x**2, "g>")

    # filled paths and patterns
    plt.fill_between([0., .4], [.4, 0.], hatch='//', facecolor="lightgray",
                     edgecolor="red")
    plt.fill([3, 3, .8, .8, 3], [2, -2, -2, 0, 2], "b")

    # text and typesetting
    plt.plot([0.9], [0.5], "ro", markersize=3)
    plt.text(0.9, 0.5, 'unicode (ü, °, µ) and math ($\\mu_i = x_i^2$)',
             ha='right', fontsize=20)
    plt.ylabel('sans-serif, blue, $\\frac{\\sqrt{x}}{y^2}$..',
               family='sans-serif', color='blue')

    plt.xlim(0, 1)
    plt.ylim(0, 1)


# test compiling a figure to pdf with xelatex 
开发者ID:holzschu,项目名称:python3_ios,代码行数:29,代码来源:test_backend_pgf.py

示例8: display

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def display(x, color, list_save=None) :
    kde  = KernelDensity(kernel='gaussian', bandwidth= .005 ).fit(x.data.cpu().numpy())
    dens = np.exp( kde.score_samples(t_plot) )
    dens[0] = 0 ; dens[-1] = 0;
    plt.fill(t_plot, dens, color=color)
    if list_save is not None :
        list_save.append(dens.ravel()) # We'll save a csv at the end 
开发者ID:jeanfeydy,项目名称:global-divergences,代码行数:9,代码来源:gradient_flow_1D.py

示例9: _plot_sequence

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def _plot_sequence(self, seq, ro_ind, x_unit, bounds, col = "C0", plot_readout = True):
        """
        The actual plotting of the sequences happens here.
        
        Input:
            seq:    sequence (as array) to be plotted
            ro_ind: index of the readout in seq
            x_unit: x_unit for the time axis
            bounds: boundaries for the plot (xmin, xmax, ymin, ymax)
        """
        if not qkit.module_available("matplotlib"):
            raise ImportError("matplotlib not found.")
        
        if plot_readout:
            fig = plt.figure(figsize = (18, 6))
        xmin, xmax, ymin, ymax = bounds
        samplerate = self._sample.clock
        time = -(np.arange(0, len(seq) + 1, 1) - ro_ind) / (samplerate * self._x_unit[x_unit])
        # make sure last point of the waveform goes to zero
        seq = np.append(seq, 0)

        # plot sequence
        plt.plot(time, seq, col)
        plt.fill(time, seq, color = col, alpha = 0.2)
        # plot readout
        if plot_readout:
            plt.fill([0, 0, - self._sample.readout_tone_length / self._x_unit[x_unit], - self._sample.readout_tone_length / self._x_unit[x_unit]], 
                    [0, ymax, ymax, 0], color = "C7", alpha = 0.3)        
            # add label for readout
            plt.text(-0.5*self._sample.readout_tone_length / self._x_unit[x_unit], ymax/2.,
                    "readout", horizontalalignment = "center", verticalalignment = "center", rotation = 90, size = 14)
        # adjust bounds
        plt.xlim(xmin + 0.005 * abs(xmax - xmin), xmax - 0.006 * abs(xmax - xmin))
        plt.ylim(ymin, ymax + 0.025 * (ymax - ymin))
        plt.xlabel("time " + x_unit)
        return 
开发者ID:qkitgroup,项目名称:qkit,代码行数:38,代码来源:VirtualAWG.py

示例10: _plot_sequences

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def _plot_sequences(self, seq_ind, seqs, ro_inds, x_unit, bounds):
        """
        The actual plotting of the sequences happens here.
        
        Args:
            seqs:            list of sequences to be plotted (i.e. one list of sequence for each channel)
            ro_inds:         indices of the readout
            x_unit:          x_unit for the time axis
            bounds:          boundaries of the plot (xmin, xmax, ymin, ymax)
            show_quadrature: set to "I" or "Q" if you want to display either quadrature instead of the amplitude
        """
        if not qkit.module_available("matplotlib"):
            raise ImportError("matplotlib not found.")

        fig = plt.figure(figsize=(18,6))
        xmin, xmax, ymin, ymax = bounds
        samplerate = self._sample.clock
        # plot sequence
        for i, chan in enumerate(self.channels[1:]):
            if len(ro_inds[i]) > seq_ind:
                chan._plot_sequence(seqs[i][seq_ind], ro_inds[i][seq_ind], x_unit, bounds, col = self._chancols[i + 1], plot_readout = False)
        
            # plot readout
        plt.fill([0, 0, - self._sample.readout_tone_length / self._x_unit[x_unit], - self._sample.readout_tone_length / self._x_unit[x_unit]], 
                [0, ymax, ymax, 0], color = "C7", alpha = 0.3)
        # add label for readout
        plt.text(-0.5*self._sample.readout_tone_length / self._x_unit[x_unit], ymax/2.,
                "readout", horizontalalignment = "center", verticalalignment = "center", rotation = 90, size = 14)
        
        # adjust plot limits
        plt.xlim(xmin + 0.005 * abs(xmax - xmin), xmax - 0.006 * abs(xmax - xmin))
        plt.ylim(ymin, ymax + 0.025 * (ymax - ymin))
        plt.xlabel("time " + x_unit)
        return 
开发者ID:qkitgroup,项目名称:qkit,代码行数:36,代码来源:VirtualAWG.py

示例11: plot_visible_slice

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def plot_visible_slice(
        self, level, outline_prec=1.0e-2, plot_srgb_gamut=True, fill_color="0.8"
    ):
        # first plot the monochromatic outline
        mono_xy, conn_xy = get_mono_outline_xy(
            observer=cie_1931_2(), max_stepsize=outline_prec
        )

        mono_vals = numpy.array([self._bisect(xy, self.k0, level) for xy in mono_xy])
        conn_vals = numpy.array([self._bisect(xy, self.k0, level) for xy in conn_xy])

        k1, k2 = [k for k in [0, 1, 2] if k != self.k0]
        plt.plot(mono_vals[:, k1], mono_vals[:, k2], "-", color="k")
        plt.plot(conn_vals[:, k1], conn_vals[:, k2], ":", color="k")
        #
        if fill_color is not None:
            xyz = numpy.vstack([mono_vals, conn_vals[1:]])
            plt.fill(xyz[:, k1], xyz[:, k2], facecolor=fill_color, zorder=0)

        if plot_srgb_gamut:
            self._plot_srgb_gamut(self.k0, level)

        plt.axis("equal")
        plt.xlabel(self.labels[k1])
        plt.ylabel(self.labels[k2])
        plt.title(f"{self.labels[self.k0]} = {level}") 
开发者ID:nschloe,项目名称:colorio,代码行数:28,代码来源:_color_space.py

示例12: _plot_monochromatic

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def _plot_monochromatic(observer, xy_to_2d, fill_horseshoe=True):
    # draw outline of monochromatic spectra
    lmbda = 1.0e-9 * numpy.arange(380, 701)
    values = []
    # TODO vectorize (see <https://github.com/numpy/numpy/issues/10439>)
    for k, _ in enumerate(lmbda):
        data = numpy.zeros(len(lmbda))
        data[k] = 1.0
        values.append(_xyy_from_xyz100(spectrum_to_xyz100((lmbda, data), observer))[:2])
    values = numpy.array(values)

    # Add the values between the first and the last point of the horseshoe
    t = numpy.linspace(0.0, 1.0, 101)
    connect = xy_to_2d(numpy.outer(values[0], t) + numpy.outer(values[-1], 1 - t))
    values = xy_to_2d(values.T).T
    full = numpy.concatenate([values, connect.T])

    # fill horseshoe area
    if fill_horseshoe:
        plt.fill(*full.T, color=[0.8, 0.8, 0.8], zorder=0)
    # plot horseshoe outline
    plt.plot(
        values[:, 0],
        values[:, 1],
        "-k",
        # label="monochromatic light"
    )
    # plot dotted connector
    plt.plot(connect[0], connect[1], ":k")
    return 
开发者ID:nschloe,项目名称:colorio,代码行数:32,代码来源:_tools.py

示例13: cl_dist_map

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def cl_dist_map(x,y,z,xmin,xmax,ymin,ymax,dx):
    """function for centerline rasterization and distance map calculation (does not return zmap)
    used for cutoffs only 
    inputs:
    x,y,z - coordinates of centerline
    xmin, xmax, ymin, ymax - x and y coordinates that define the area of interest
    dx - gridcell size (m)
    returns:
    cl_dist - distance map (distance from centerline)
    x_pix, y_pix, - x and y pixel coordinates of the centerline
    """
    y = y[(x>xmin) & (x<xmax)]
    z = z[(x>xmin) & (x<xmax)]
    x = x[(x>xmin) & (x<xmax)]    
    xdist = xmax - xmin
    ydist = ymax - ymin
    iwidth = int((xmax-xmin)/dx)
    iheight = int((ymax-ymin)/dx)
    xratio = iwidth/xdist
    # create list with pixel coordinates:
    pixels = []
    for i in range(0,len(x)):
        px = int(iwidth - (xmax - x[i]) * xratio)
        py = int(iheight - (ymax - y[i]) * xratio)
        pixels.append((px,py))
    # create image and numpy array:
    img = Image.new("RGB", (iwidth, iheight), "white")
    draw = ImageDraw.Draw(img)
    draw.line(pixels, fill="rgb(0, 0, 0)") # draw centerline as black line
    pix = np.array(img)
    cl = pix[:,:,0]
    cl[cl==255] = 1 # set background to 1 (centerline is 0)
    # calculate Euclidean distance map:
    cl_dist, inds = ndimage.distance_transform_edt(cl, return_indices=True)
    y_pix,x_pix = np.where(cl==0)
    return cl_dist, x_pix, y_pix 
开发者ID:zsylvester,项目名称:meanderpy,代码行数:38,代码来源:meanderpy.py

示例14: PlotCompTable

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def PlotCompTable(CompTable):

  for CT in CompTable:

    X = [CT[2], CT[3], CT[3], CT[2], CT[2]]
    Y = [CT[0], CT[0], CT[0]+CT[1], CT[0]+CT[1], CT[0]]

    plt.plot(X, Y, 'r--', linewidth=2)
    plt.fill(X, Y, color='y',alpha=0.1)

#----------------------------------------------------------------------------------------- 
开发者ID:igp-gravity,项目名称:geoist,代码行数:13,代码来源:Exploration.py

示例15: _blob

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import fill [as 别名]
def _blob(x, y, w, w_max, area, cmap=None):
    """
    Draws a square-shaped blob with the given area (< 1) at the given coordinates.
    """
    hs = np.sqrt(area) / 2
    xcorners = np.array([x - hs, x + hs, x + hs, x - hs])
    ycorners = np.array([y - hs, y - hs, y + hs, y + hs])

    plt.fill(xcorners, ycorners, color=cmap)  # cmap(int((w + w_max) * 256 / (2 * w_max))))


# Modified from QuTip (see https://bit.ly/2LrbayH ) which in turn modified the code from the
# SciPy Cookbook. 
开发者ID:rigetti,项目名称:forest-benchmarking,代码行数:15,代码来源:hinton.py


注:本文中的matplotlib.pyplot.fill方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。