本文整理汇总了Python中matplotlib.backend_bases.FigureCanvasBase.get_default_filename方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasBase.get_default_filename方法的具体用法?Python FigureCanvasBase.get_default_filename怎么用?Python FigureCanvasBase.get_default_filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backend_bases.FigureCanvasBase
的用法示例。
在下文中一共展示了FigureCanvasBase.get_default_filename方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_default_filename
# 需要导入模块: from matplotlib.backend_bases import FigureCanvasBase [as 别名]
# 或者: from matplotlib.backend_bases.FigureCanvasBase import get_default_filename [as 别名]
def test_get_default_filename():
try:
test_dir = tempfile.mkdtemp()
plt.rcParams['savefig.directory'] = test_dir
fig = plt.figure()
canvas = FigureCanvasBase(fig)
filename = canvas.get_default_filename()
assert filename == 'image.png'
finally:
shutil.rmtree(test_dir)
示例2: test_get_default_filename_already_exists
# 需要导入模块: from matplotlib.backend_bases import FigureCanvasBase [as 别名]
# 或者: from matplotlib.backend_bases.FigureCanvasBase import get_default_filename [as 别名]
def test_get_default_filename_already_exists():
# From #3068: Suggest non-existing default filename
try:
test_dir = tempfile.mkdtemp()
plt.rcParams['savefig.directory'] = test_dir
fig = plt.figure()
canvas = FigureCanvasBase(fig)
# create 'image.png' in figure's save dir
open(os.path.join(test_dir, 'image.png'), 'w').close()
filename = canvas.get_default_filename()
assert filename == 'image-1.png'
finally:
shutil.rmtree(test_dir)
示例3: test_get_default_filename
# 需要导入模块: from matplotlib.backend_bases import FigureCanvasBase [as 别名]
# 或者: from matplotlib.backend_bases.FigureCanvasBase import get_default_filename [as 别名]
def test_get_default_filename(tmpdir):
plt.rcParams['savefig.directory'] = str(tmpdir)
fig = plt.figure()
canvas = FigureCanvasBase(fig)
filename = canvas.get_default_filename()
assert filename == 'image.png'