温馨提示×

python中figure是什么意思

摘星
1272
2021-05-31 18:24:52
栏目: 编程语言

python中figure是指一个模块,figure模块提供了顶层Artist并且包含所有绘图元素,主要用来控制所有图元的子图和顶层容器的默认间距。

python中figure是什么意思

具体使用步骤:

1、首先打开python编辑器,新建一个python项目。

2、在python项目中使用import关键字导入matplotlib库进行使用即可。

import matplotlib.pyplot as plt #导入matplotlib库并简化名为plt

3、再输入以下代码创建一个自定义图像并通过show()方法显示即可。

fig=plt.figure(figsize=(4,3),facecolor=‘blue')

plt.show()

figure语法

figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True)

参数分析

num:图像编号或名称,数字为编号 ,字符串为名称

figsize:指定figure的宽和高,单位为英寸;

dpi:指定绘图对象的分辨率,即每英寸多少个像素,缺省值为80 1英寸等于2.5cm,A4纸是 21*30cm的纸张

facecolor:背景颜色

edgecolor:边框颜色

frameon:是否显示边框

0