Home > Net >  How can I add a .png watermark to a graph made on matplotlib?
How can I add a .png watermark to a graph made on matplotlib?

Time:01-21

I'd like to add a watermark over charts using matplotlib (but under the lines/points/bars plotted), using a .png image. I'm having trouble doing this without ruining the graph in the process.

The following code makes a simple chart in matplotlib:

import matplotlib.pyplot as plt

def MakePlotWithWatermark():
    fig, ax = plt.subplots(figsize = (10, 5))
    ax.grid(True, which='both', axis='both', linestyle='--', linewidth=0.5)
    ax.plot([1, 2, 3, 4, 5], [1, 4, 9, 16, 25], marker='o', color = "Blue")
    plt.close()
    return fig

This works as expected, giving this as enter image description here

  • Related