python数据分析得到的图片,并对照片添加水印pillow
PIL包含在pillow中,所以如果要从PIL导入相关库需要安装pillow
# install
pip install pillow
安装完之后就可以下面的头文件来操作了
from PIL import Image, ImageDraw
采用函数式编程:
#!/usr/bin/python
from PIL import Image, ImageDraw
from matplotlib import pyplot as plt, font_manager
# 保存通过数据分析得到的图片
def save_img():
# mac系统下查询包含中文字体的方式是命令fc-list :lang=zh
my_font = font_manager.FontProperties( fname="/System/Library/Assets/com_apple_MobileAsset_Font5/b2d7b382c0fbaa5777103242eb048983c40fb807.asset/AssetData/Kaiti.ttc")
x = [i for i in range(11, 31)]
y_1 = [1, 0, 1, 1, 2<