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


Python Polygon.append方法代码示例

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


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

示例1: plot_params_1d

# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import append [as 别名]
def plot_params_1d(input_fits, parameter, output_dir=None,
                   select_format=("N", 1), log_x=False, log_y=True,
                   label=None, bins=30, additional={}, plot_name=True,
                   format='pdf'):
    """
    Make histogram plots of parameters

    Parameters
    ----------
    input_fits : str or :class:`sedfitter.fit_info.FitInfo` or iterable
        This should be either a file containing the fit information, a
        :class:`sedfitter.fit_info.FitInfo` instance, or an iterable containing
        :class:`sedfitter.fit_info.FitInfo` instances.
    parameter : str
        The parameter to plot a histogram of
    output_dir : str, optional
        If specified, plots are written to that directory
    select_format : tuple, optional
        Tuple specifying which fits should be plotted. See the documentation
        for a description of the tuple syntax.
    log_x : bool, optional
        Whether to plot the x-axis values in log space
    log_y : bool, optional
        Whether to plot the y-axis values in log space
    label : str, optional
        The x-axis label (if not specified, the parameter name is used)
    bins : int, optional
        The number of bins for the histogram
    additional : dict, optional
        A dictionary specifying additional parameters not listed in the
        parameter list for the models. Each item of the dictionary should
        itself be a dictionary giving the values for each model (where the key
        is the model name).
    plot_name: bool, optional
        Whether to show the source name on the plot(s).
    format: str, optional
        The file format to use for the plot, if output_dir is specified.

    """

    if output_dir is None:
        raise ValueError("No output directory has been specified")
    # Create output directory
    io.create_dir(output_dir)

    # Open input file
    fin = FitInfoFile(input_fits, 'r')

    # Read in table of parameters for model grid
    t = load_parameter_table(fin.meta.model_dir)

    # Sort alphabetically
    t['MODEL_NAME'] = np.char.strip(t['MODEL_NAME'])
    t.sort('MODEL_NAME')
    tpos = deepcopy(t)
    if log_x:
        tpos = tpos[tpos[parameter] > 0.]

    # Initialize figure
    fig = plt.figure()
    ax = get_axes(fig)

    # Find range of values
    pmin, pmax = tpos[parameter].min(), tpos[parameter].max()

    # Compute histogram
    if log_x:
        hist_all, edges = np.histogram(np.log10(tpos[parameter]), bins=bins, range=[np.log10(pmin), np.log10(pmax)])
        center = (edges[1:] + edges[:-1]) / 2.
        edges, center = 10. ** edges, 10. ** center
    else:
        hist_all, edges = np.histogram(t[parameter], bins=bins, range=[pmin, pmax])
        center = (edges[1:] + edges[:-1]) / 2.

    # Grayscale showing all models
    p = []
    for i in range(len(hist_all)):
        p.append((edges[i], max(hist_all[i], 0.01)))
        p.append((edges[i + 1], max(hist_all[i], 0.01)))
    p.append((edges[-1], 0.01))
    p.append((edges[0], 0.01))

    p = Polygon(p, facecolor='0.8', edgecolor='none')
    ax.add_patch(p)

    ax.set_xlabel(parameter if label is None else label)

    if log_x:
        ax.set_xscale('log')
        ax.xaxis.set_major_formatter(LogFormatterMathtextAuto())
    if log_y:
        ax.set_yscale('log')
        ax.yaxis.set_major_formatter(LogFormatterMathtextAuto())

    ax.set_xlim(pmin, pmax)
    ax.set_ylim(0.1, hist_all.max() * 10.)

    ax.set_autoscale_on(False)

    pfits = None
#.........这里部分代码省略.........
开发者ID:astroswag,项目名称:sedfitter,代码行数:103,代码来源:plot_params_1d.py


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