网络编程
位置:首页>> 网络编程>> Python编程>> plt.figure()参数使用详解及运行演示

plt.figure()参数使用详解及运行演示

作者:超级-马里奥  发布时间:2021-11-01 04:52:19 

标签:plt.figure(),参数

1.figure语法及操作

(1)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:是否显示边框

(2)例子:


import matplotlib.pyplot as plt

创建自定义图像


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

2.subplot创建单个子图

(1) subplot语法


subplot(nrows,ncols,sharex,sharey,subplot_kw,**fig_kw)

plt.figure()参数使用详解及运行演示

代码运行及演示
plt.figure()参数使用详解及运行演示

plt.figure()参数使用详解及运行演示

plt.figure()参数使用详解及运行演示

plt.figure()参数使用详解及运行演示

plt.figure()参数使用详解及运行演示

plt.figure()参数使用详解及运行演示

plt.figure(figsize=(a,b))和plt.subplot()函数区别

plt.figure(figsize=(6,8))
表示figure 的大小为宽、长(单位为inch)

figsize : (float, float), optional, default: None
width, height in inches. If not provided, defaults to
rcParams[“figure.figsize”] = [6.4, 4.8].

plt.subplot(121)
表示整个figure分成1行2列,共2个子图,这里子图在第一行第一列

plt.figure()参数使用详解及运行演示

plt.subplot(122)

表示子图在第一行第二列

plt.figure()参数使用详解及运行演示

来源:https://blog.csdn.net/baoziqyp/article/details/111239877

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com