import numpy as np
import matplotlib.pyplot as plt


def plot_spectrum(shifts, peak=1, width=2, padding=0, res=1000,
                  x_min=None, x_max=None, x_label=None, y_label=None):
    if x_min is None:
        x_min = min(shifts) - padding
    if x_max is None:
        x_max = max(shifts) + padding
    if isinstance(peak, (int, float)):
        peak = np.ones_like(shifts) * peak
    if isinstance(width, (int, float)):
        width = np.ones_like(shifts) * width
    x = np.linspace(x_min, x_max, res)
    y = np.zeros_like(x)
    gamma = width / 2.0
    for s, p, w in zip(shifts, peak, width):
        y += p * (1.0 / np.pi) * (w / ((x - s)**2 + w**2))
    plt.plot(x, y, color='black', lw=1.5)
    if x_label is not None:
        plt.xlabel(x_label)
    if y_label is not None:
        plt.ylabel(y_label)
    return plt
