initial upload
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"\n# Exercise 8\n\nExercise 8 with matplotlib.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"collapsed": false
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\nimport matplotlib.pyplot as plt\n\nplt.figure(figsize=(8, 5), dpi=80)\nplt.subplot(111)\n\nX = np.linspace(-np.pi, np.pi, 256, endpoint=True)\nC = np.cos(X)\nS = np.sin(X)\n\nplt.plot(X, C, color=\"blue\", linewidth=2.5, linestyle=\"-\", label=\"cosine\")\nplt.plot(X, S, color=\"red\", linewidth=2.5, linestyle=\"-\", label=\"sine\")\n\nax = plt.gca()\nax.spines[\"right\"].set_color(\"none\")\nax.spines[\"top\"].set_color(\"none\")\nax.xaxis.set_ticks_position(\"bottom\")\nax.spines[\"bottom\"].set_position((\"data\", 0))\nax.yaxis.set_ticks_position(\"left\")\nax.spines[\"left\"].set_position((\"data\", 0))\n\nplt.xlim(X.min() * 1.1, X.max() * 1.1)\nplt.xticks(\n [-np.pi, -np.pi / 2, 0, np.pi / 2, np.pi],\n [r\"$-\\pi$\", r\"$-\\pi/2$\", r\"$0$\", r\"$+\\pi/2$\", r\"$+\\pi$\"],\n)\n\nplt.ylim(C.min() * 1.1, C.max() * 1.1)\nplt.yticks([-1, +1], [r\"$-1$\", r\"$+1$\"])\n\nplt.legend(loc=\"upper left\")\n\nplt.show()"
|
||||
]
|
||||
}
|
||||
],
|
||||
"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.12.11"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
Reference in New Issue
Block a user