python去除图片水印_Python | 图中使用类的水印

python去除图片水印

Sometimes, we need to add watermark as a standard category of plots and therefore, we are introducing a new methodology for adding watermark in this article.

有时,我们需要将水印添加为地块的标准类别,因此,我们在本文中介绍了一种添加水印的新方法。

使用类的图中水印的Python代码 (Python code for watermark in figure using class)

# Data Visualization using Python
# WaterMark in Figure

import matplotlib.pyplot as plt
from matplotlib.figure import Figure
import numpy as np

class WatermarkFigure(Figure):
    def __init__(self, *args, watermark=None, **kwargs):
        super().__init__(*args, **kwargs)

        if watermark is not None:
            bbox = dict(boxstyle='square', lw=3, ec='gray',
                        fc=(0.9, 0.9, .9, .5), alpha=0.3)
            self.text(0.5, 0.5, watermark,
                      ha='center', va='center',
                      fontsize=40, color='gray', alpha=0.3, bbox=bbox)


x = np.linspace(-3, 3, 201)
y = np.exp(-x) + 0.1 * np.cos(5 * x)

plt.figure(FigureClass=WatermarkFigure, watermark='Watermark')
plt.plot(x, y)

Output:

输出:

Output is as figure


翻译自: https://www.includehelp.com/python/watermark-in-figure-using-class.aspx

python去除图片水印

你可能感兴趣的:(python去除图片水印_Python | 图中使用类的水印)