from pylab import * import matplotlib.pyplot as plt def lines(): xs = range(100) ys = [x**2 for x in xs] ys2 = [2 * (x**2) for x in xs] ys3 = [4 * (x**2) for x in xs] plt.title('Lines') plt.xlabel('X') plt.ylabel('Y') plt.plot(xs, ys) plt.plot(xs, ys2) plt.plot(xs, ys3) plt.show() # lines() def scatterplot(): plt.title('Scatterplot') plt.xlabel('X') plt.ylabel('Y') x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] y = [2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13] for index in range(len(x)): plt.scatter(x[index], y[index], c = 'blue') plt.show() # scatterplot() def histogram(): x = [1, 2, 3, 4] freqs = [10, 11, 15, 5] #width of bins width = .5 plt.xlim([1, 5]) plt.title("Histogram") plt.xlabel('Quarter') plt.ylabel('Frequency of Robberies') plt.bar(x, freqs, width, color = 'm') plt.show() histogram() def pie_chart(): #creates the figure with specified size figure(1, figsize=(7, 7)) #centers the figure ax = axes([.2, .2, .6, .6]) colors = ['red', 'green', 'white', 'yellow'] labels = ['cat', 'dog', 'fish', 'bird'] frequencies = [11, 24, 37, 8] #autopct places the percentages inside their corresponding section plt.pie(frequencies, colors = colors, labels = labels, autopct = '%1.1f%%') plt.title('Pets Owned') plt.show() # pie_chart()