Generate Python code to generate a histogram from a given data set.
data = [1, 3, 5, 3, 2, 6, 8, 1, 2]
import matplotlib.pyplot as plt 

def generate_histogram(data):
    plt.hist(data)
    plt.xlabel("Data")
    plt.ylabel("Frequency")
    plt.title("Histogram of Data")
    plt.show()
    
generate_histogram(data)