Use record of matplotlib module in Python language (personal version)

1. Referenced basic common python modules

import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np

2. In order to display Chinese in the horizontal and vertical coordinates, corresponding settings need to be made

# 经过此项设置,可以使用于显示的可视化坐标图中显示中文
mpl.rcParams["font.sans-serif"] = ["SimHei"]

3. Acquisition of the corresponding values ​​of the x and y axes

x = np.arange(start=-10, stop=10, step=0.1)
y = []
for t in x:
    y_t = 1 / (1 + math.exp(-t))
    y.append(y_t)

4. Some parameter settings of the image, plt.figure()

plt.figure(dpi=80,figsize=(18,8))
"""
plt.figure()参数说明
num:图像编号或名称
figsize:指定figure的宽和高,单位为名称
dpi:指定绘图对象的分辨率,意思是每英寸多少个像素,缺省值为80,1英寸为2.5cm,A4纸的21*30cm
facecolor:背景颜色
edgecolor:边框颜色
frameon:是否显示边框
"""
plt.figure(num=1, figsize=(18, 8),
           dpi=100,  # defaults to rc figure.dpi
           facecolor="pink",  # defaults to rc figure.facecolor
           edgecolor="green",  # defaults to rc figure.edgecolor
           )

As shown in Figure 1, the middle is the generated sin function image, and the horizontal and vertical coordinates have not been set

 Figure 1 Effect diagram of some parameter settings of plt.figure() 

December 1, 2022, 20:55:21, that's all for today, to be continued...

Guess you like

Origin blog.csdn.net/hacker_NO_007/article/details/128137949