本文整理汇总了Python中matplotlib.colorbar.__doc__方法的典型用法代码示例。如果您正苦于以下问题:Python colorbar.__doc__方法的具体用法?Python colorbar.__doc__怎么用?Python colorbar.__doc__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.colorbar
的用法示例。
在下文中一共展示了colorbar.__doc__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_pyplot_info_docstrings
# 需要导入模块: from matplotlib import colorbar [as 别名]
# 或者: from matplotlib.colorbar import __doc__ [as 别名]
def _setup_pyplot_info_docstrings():
"""
Generates the plotting and docstring.
These must be done after the entire module is imported, so it is
called from the end of this module, which is generated by
boilerplate.py.
"""
# Generate the plotting docstring
import re
def pad(s, l):
"""Pad string *s* to length *l*."""
if l < len(s):
return s[:l]
return s + ' ' * (l - len(s))
commands = get_plot_commands()
first_sentence = re.compile("(?:\s*).+?\.(?:\s+|$)", flags=re.DOTALL)
# Collect the first sentence of the docstring for all of the
# plotting commands.
rows = []
max_name = 0
max_summary = 0
for name in commands:
doc = globals()[name].__doc__
summary = ''
if doc is not None:
match = first_sentence.match(doc)
if match is not None:
summary = match.group(0).strip().replace('\n', ' ')
name = '`%s`' % name
rows.append([name, summary])
max_name = max(max_name, len(name))
max_summary = max(max_summary, len(summary))
lines = []
sep = '=' * max_name + ' ' + '=' * max_summary
lines.append(sep)
lines.append(' '.join([pad("Function", max_name),
pad("Description", max_summary)]))
lines.append(sep)
for name, summary in rows:
lines.append(' '.join([pad(name, max_name),
pad(summary, max_summary)]))
lines.append(sep)
plotting.__doc__ = '\n'.join(lines)
## Plotting part 1: manually generated functions and wrappers ##
示例2: _setup_pyplot_info_docstrings
# 需要导入模块: from matplotlib import colorbar [as 别名]
# 或者: from matplotlib.colorbar import __doc__ [as 别名]
def _setup_pyplot_info_docstrings():
"""
Generates the plotting docstring.
These must be done after the entire module is imported, so it is
called from the end of this module, which is generated by
boilerplate.py.
"""
commands = get_plot_commands()
first_sentence = re.compile(r"(?:\s*).+?\.(?:\s+|$)", flags=re.DOTALL)
# Collect the first sentence of the docstring for all of the
# plotting commands.
rows = []
max_name = len("Function")
max_summary = len("Description")
for name in commands:
doc = globals()[name].__doc__
summary = ''
if doc is not None:
match = first_sentence.match(doc)
if match is not None:
summary = inspect.cleandoc(match.group(0)).replace('\n', ' ')
name = '`%s`' % name
rows.append([name, summary])
max_name = max(max_name, len(name))
max_summary = max(max_summary, len(summary))
separator = '=' * max_name + ' ' + '=' * max_summary
lines = [
separator,
'{:{}} {:{}}'.format('Function', max_name, 'Description', max_summary),
separator,
] + [
'{:{}} {:{}}'.format(name, max_name, summary, max_summary)
for name, summary in rows
] + [
separator,
]
plotting.__doc__ = '\n'.join(lines)
## Plotting part 1: manually generated functions and wrappers ##
示例3: _setup_pyplot_info_docstrings
# 需要导入模块: from matplotlib import colorbar [as 别名]
# 或者: from matplotlib.colorbar import __doc__ [as 别名]
def _setup_pyplot_info_docstrings():
"""
Generates the plotting and docstring.
These must be done after the entire module is imported, so it is
called from the end of this module, which is generated by
boilerplate.py.
"""
# Generate the plotting docstring
import re
def pad(s, l):
"""Pad string *s* to length *l*."""
if l < len(s):
return s[:l]
return s + ' ' * (l - len(s))
commands = get_plot_commands()
first_sentence = re.compile(r"(?:\s*).+?\.(?:\s+|$)", flags=re.DOTALL)
# Collect the first sentence of the docstring for all of the
# plotting commands.
rows = []
max_name = 0
max_summary = 0
for name in commands:
doc = globals()[name].__doc__
summary = ''
if doc is not None:
match = first_sentence.match(doc)
if match is not None:
summary = match.group(0).strip().replace('\n', ' ')
name = '`%s`' % name
rows.append([name, summary])
max_name = max(max_name, len(name))
max_summary = max(max_summary, len(summary))
lines = []
sep = '=' * max_name + ' ' + '=' * max_summary
lines.append(sep)
lines.append(' '.join([pad("Function", max_name),
pad("Description", max_summary)]))
lines.append(sep)
for name, summary in rows:
lines.append(' '.join([pad(name, max_name),
pad(summary, max_summary)]))
lines.append(sep)
plotting.__doc__ = '\n'.join(lines)
## Plotting part 1: manually generated functions and wrappers ##