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(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.subplot(122) 表示子图在第一行第二列 fig=plt.figure(figsize=(float(image.size[0])/my_dpi,float(image.size[1])/my_dpi),dpi=my_dpi) ax=fig.add_subplot(111) # Remove whitespace from around the image fig.subplots_adjust(left=0,right=1,bottom=0,top=1)
python之plt.figure
最新推荐文章于 2024-05-03 11:07:56 发布