{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "\n", "def show_scatter_plot(title, \n", " x_label, y_label, \n", " x_values, y_values):\n", " \"\"\"\n", " @param title the chart title.\n", " @param x_label the x-axis label.\n", " @param y_label the y-axis label.\n", " @param x_values the independent x values to plot.\n", " @param y_values the dependent y values to plot.\n", " \"\"\"\n", " plt.scatter(x_values, y_values)\n", " plt.title(title)\n", " plt.ylabel(x_label)\n", " plt.xlabel(y_label)\n", " plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "xs = [32, 37, 38, 40, 45, 50, 50, 54, 54, 55, \n", " 61, 63, 63, 64, 64, 70, 70, 75, 76]\n", "ys = [18.3, 18.9, 19.0, 20.9, 21.4, 20.5, 20.1, 20.1, 20.8, 20.5, \n", " 19.9, 20.5, 20.6, 22.1, 21.9, 21.2, 20.5, 22.7, 22.8]\n", "\n", "show_scatter_plot('Scatter Plot', 'Dependent variable', \n", " 'Independent variable', xs, ys )" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "xs = range(2, 26)\n", "ys = [10,12,20,22,21,25,30,21,32,34,35,30,50,45,55,60,66,64,67,72,74,80,79,84]\n", "\n", "show_scatter_plot('Scatter Plot', 'Dependent variable', 'Independent variable', xs, ys )" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.7" } }, "nbformat": 4, "nbformat_minor": 4 }