{ "cells": [ { "cell_type": "markdown", "id": "6838b2de", "metadata": {}, "source": [ "# Hello" ] }, { "cell_type": "code", "execution_count": null, "id": "4200d243", "metadata": {}, "outputs": [], "source": [ "\"\"\"\n", " Yet another version to plot cos in the range 0 -> 4pi using Numpy\n", " (the numerical package) to do all the work\n", "\n", " This is beyond this course, but you will learn Numpy next year.\n", "\"\"\"\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "\n", "def main():\n", "\n", " thetaData = np.linspace(0,4.0*np.pi,300) # Create a linear space from 0->4pi with 300 points\n", "\n", " # Use numpy functions np.degrees and np.cos that both return numpy arrays\n", " plt.plot(np.degrees(thetaData),np.cos(thetaData))\n", " # Add the title\n", " plt.title(\"Cos Plot using Numpy\")\n", " plt.xlabel(\"Angle in degrees\")\n", " plt.ylabel(\"Cos\")\n", " plt.show() # Do the actual plot\n", "\n", "main()\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.7" } }, "nbformat": 4, "nbformat_minor": 5 }