本文整理汇总了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
#.........这里部分代码省略.........